Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected "Unnecessary using directive." diagnostics is reported #39941

Open
AlekseyTs opened this issue Nov 21, 2019 · 0 comments
Open

Unexpected "Unnecessary using directive." diagnostics is reported #39941

AlekseyTs opened this issue Nov 21, 2019 · 0 comments

Comments

@AlekseyTs
Copy link
Contributor

Using this VB assembly as a reference

Public Class C1
    Public Shared Property P1(x As Integer)
        Get
            Return Nothing
        End Get
        Set
        End Set
    End Property
End Class

compile this C# code

using static C1;

public class C2
{
    public static void Main()
    {
        P1[0] = null;
    }
}

Observed:

// (2,1): hidden CS8019: Unnecessary using directive.
// using static C1;
Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using static C1;").WithLocation(2, 1),
// (8,9): error CS1545: Property, indexer, or event 'C1.P1[int]' is not supported by the language; try directly calling accessor methods 'C1.get_P1(int)' or 'C1.set_P1(int, object)'
//         P1[0] = null;
Diagnostic(ErrorCode.ERR_BindToBogusProp2, "P1").WithArguments("C1.P1[int]", "C1.get_P1(int)", "C1.set_P1(int, object)").WithLocation(8, 9)

Expected: No CS8019 diagnostics, if there were no that using directive, P1 wouldn't be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant