dotnet/roslyn

Unexpected 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 2017年2月1日

GitHub で見る
 (0 comments) (0 reactions) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-CompilersBugLanguage-VBhelp wanted

説明

        <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

コントリビューターガイド