dotnet/roslyn

Compiler gives me extraneous errors about late binding when I'm missing an assembly reference

オープン

#10,186 opened on 2016/03/29

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-CompilersBugConcept-Diagnostic ClarityLanguage-VBhelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (PR metrics pending)

説明

I have the following code:

        Private Function NamespaceIsReferenceableFromCompilation([namespace] As INamespaceSymbol, compilation As Compilation) As Boolean
            For Each type In [namespace].GetTypeMembers()
                If type.CanBeReferencedByName Then
                    If type.DeclaredAccessibility = CodeAnalysis.Accessibility.Public Then
                        Return True
                    End If

                    If type.ContainingAssembly.Equals(compilation.Assembly) OrElse type.ContainingAssembly.GivesAccessTo(compilation.Assembly) Then
                        Return True
                    End If
                End If
            Next

            Return False
        End Function

The compiler correctly gives me an error about missing an assembly reference:

Error   BC30652 Reference required to assembly 'System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the type 'ImmutableArray(Of )'. Add one to your project.   Microsoft.VisualStudio.Editors  C:\Roslyn With Spaces\src\ProjectSystem\Microsoft.VisualStudio.Editors\proppages\ReferencePropPage.vb   951 Active

But then goes complaining that I can't late bind:

image

Error   BC30574 Option Strict On disallows late binding.    Microsoft.VisualStudio.Editors  C:\Roslyn With Spaces\src\ProjectSystem\Microsoft.VisualStudio.Editors\proppages\ReferencePropPage.vb   952 Active
Error   BC30574 Option Strict On disallows late binding.    Microsoft.VisualStudio.Editors  C:\Roslyn With Spaces\src\ProjectSystem\Microsoft.VisualStudio.Editors\proppages\ReferencePropPage.vb   953 Active
Error   BC30574 Option Strict On disallows late binding.    Microsoft.VisualStudio.Editors  C:\Roslyn With Spaces\src\ProjectSystem\Microsoft.VisualStudio.Editors\proppages\ReferencePropPage.vb   957 Active
Error   BC30574 Option Strict On disallows late binding.    Microsoft.VisualStudio.Editors  C:\Roslyn With Spaces\src\ProjectSystem\Microsoft.VisualStudio.Editors\proppages\ReferencePropPage.vb   957 Active

These are completely extraneous and unrelated to my problem. The problem is that i'm missing an assembly reference, resulting in the compiler not knowing what [namespace] is; and hence can't find the members. Is there a way to mark this type as such so you don't go reporting these errors?

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