diff --git a/Amazon.IonDotnet.Tests/Common/ReaderTestCommon.cs b/Amazon.IonDotnet.Tests/Common/ReaderTestCommon.cs index ae599bce..3e7a4ec9 100644 --- a/Amazon.IonDotnet.Tests/Common/ReaderTestCommon.cs +++ b/Amazon.IonDotnet.Tests/Common/ReaderTestCommon.cs @@ -220,10 +220,7 @@ public static void ReadTypeAnnotationSymbols_ZeroSymbol(IIonReader reader) Assert.AreEqual(IonType.Int, reader.CurrentType); Assert.AreEqual(18, reader.IntValue()); Assert.AreEqual(1, reader.GetTypeAnnotationSymbols().Count()); - Assert.IsTrue(reader.GetTypeAnnotationSymbols().Any(a => a.Text == null)); - - // Commented out following assertion due to bug: https://github.com/amzn/ion-dotnet/issues/89 - //Assert.IsTrue(reader.GetTypeAnnotationSymbols().Any(a => a.Text == null && a.ImportLocation == null)); + Assert.IsTrue(reader.GetTypeAnnotationSymbols().Any(a => a.Text == null && a.ImportLocation == default)); } public static void ReadTypeAnnotationSymbols_AssertNoUnknownSymbolException(IIonReader reader) diff --git a/Amazon.IonDotnet/Internals/Text/RawTextReader.cs b/Amazon.IonDotnet/Internals/Text/RawTextReader.cs index c63cf025..dbdc75f7 100644 --- a/Amazon.IonDotnet/Internals/Text/RawTextReader.cs +++ b/Amazon.IonDotnet/Internals/Text/RawTextReader.cs @@ -535,6 +535,10 @@ private SymbolToken ParseSymbolToken(StringBuilder sb, int token) break; } + if (text == null && sid == 0) + { + return new SymbolToken(text, sid); + } return new SymbolToken(text, sid, new ImportLocation(GetSymbolTable().Name, sid)); } diff --git a/Amazon.IonDotnet/Internals/Text/SystemTextReader.cs b/Amazon.IonDotnet/Internals/Text/SystemTextReader.cs index 54e1c837..4fcb2a17 100644 --- a/Amazon.IonDotnet/Internals/Text/SystemTextReader.cs +++ b/Amazon.IonDotnet/Internals/Text/SystemTextReader.cs @@ -526,24 +526,30 @@ public override string[] GetTypeAnnotations() for (int index = 0; index < _annotations.Count; index++) { SymbolToken symbolToken = _annotations[index]; - if (symbolToken.Text is null && symbolToken.ImportLocation != default) + if (symbolToken.Text is null) { - ISymbolTable symtab = GetSymbolTable(); - - string text = symtab.FindKnownSymbol(symbolToken.ImportLocation.Sid); - if (text == null) + if (symbolToken.ImportLocation == default) { - throw new UnknownSymbolException(symbolToken.ImportLocation.Sid); + throw new UnknownSymbolException(symbolToken.Sid); } + else + { + ISymbolTable symtab = GetSymbolTable(); + + string text = symtab.FindKnownSymbol(symbolToken.ImportLocation.Sid); + if (text == null) + { + throw new UnknownSymbolException(symbolToken.ImportLocation.Sid); + } - annotations[index] = symtab.FindKnownSymbol(symbolToken.ImportLocation.Sid); + annotations[index] = symtab.FindKnownSymbol(symbolToken.ImportLocation.Sid); + } } else { annotations[index] = symbolToken.Text; } } - return annotations; }