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 ouverte le 1 févr. 2017

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)C# (4 257 forks)batch import
Area-CompilersBugLanguage-VBhelp wanted

Métriques du dépôt

Stars
 (20 414 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (256 PRs mergées en 30 j)

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

Guide contributeur