Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zero symbol to return default import location #97

Merged
merged 6 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Amazon.IonDotnet.Tests/Common/ReaderTestCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Amazon.IonDotnet/Internals/Text/RawTextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
7 changes: 5 additions & 2 deletions Amazon.IonDotnet/Internals/Text/SystemTextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ 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.ImportLocation == default)
tgregg marked this conversation as resolved.
Show resolved Hide resolved
{
throw new UnknownSymbolException(0);
}
else if (symbolToken.Text is null && symbolToken.ImportLocation != default)
{
ISymbolTable symtab = GetSymbolTable();

Expand All @@ -543,7 +547,6 @@ public override string[] GetTypeAnnotations()
annotations[index] = symbolToken.Text;
}
}

return annotations;
}

Expand Down