dotnet/roslyn
View on GitHubUnexpected value (Nothing) is returned by RootNamespace property when there are no source trees added to the compilation and embedded declarations are suppressed.
Open
#16,885 opened on Feb 1, 2017
Area-CompilersBugLanguage-VBhelp wanted
Description
<Fact()>
Public Sub RootNamespace_NoTrees_SuppressEmbeddedDeclarations()
Dim c1 = VisualBasicCompilation.Create("Test", {}, options:=TestOptions.ReleaseDll.WithRootNamespace("A.B.C").WithSuppressEmbeddedDeclarations(True))
Dim root As NamespaceSymbol = c1.RootNamespace
Assert.NotNull(root)
Assert.Equal("C", root.Name)
Assert.Equal("B", root.ContainingNamespace.Name)
Assert.Equal("A", root.ContainingNamespace.ContainingNamespace.Name)
Assert.False(root.IsGlobalNamespace)
End Sub
Result:
Unknown .NET Framework Version: v4.6
Test 'Microsoft.CodeAnalysis.VisualBasic.UnitTests.CompilationCreationTests.RootNamespace_NoTrees_SuppressEmbeddedDeclarations' failed:
Microsoft.CodeAnalysis.ThrowingTraceListener+DebugAssertFailureException : Something is deeply wrong with the declaration table or the symbol table
at Microsoft.CodeAnalysis.ThrowingTraceListener.Fail(String message, String detailMessage)
at System.Diagnostics.TraceListener.Fail(String message)
at System.Diagnostics.TraceInternal.Fail(String message)
at System.Diagnostics.Debug.Assert(Boolean condition, String message)
at Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceModuleSymbol.get_RootNamespace()
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.get_RootNamespace()
SymbolsTests\CompilationCreationTests.vb(133,0): at Microsoft.CodeAnalysis.VisualBasic.UnitTests.CompilationCreationTests.RootNamespace_NoTrees_SuppressEmbeddedDeclarations()
This affects EE, which has to work around this issue in constructor of Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.CompilationContext