dotnet/roslyn
View on GitHubCompiler gives me extraneous errors about late binding when I'm missing an assembly reference
Open
#10,186 opened on Mar 29, 2016
Area-CompilersBugConcept-Diagnostic ClarityLanguage-VBhelp wanted
Description
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:

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?