dotnet/roslyn

Improve ERR_InaccessibleSymbol2 VB diagnostic

Open

#62,790 opened on Jul 20, 2022

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-CompilersConcept-Diagnostic ClarityLanguage-VBhelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

https://github.com/dotnet/roslyn/blob/d72634113d9d36c539732aaf3a188faac26dd7d7/src/Compilers/VisualBasic/Portable/VBResources.resx#L970-L972

The diagnostic can produce the following:

Error BC30389 '{0}' is not accessible in this context because it is 'Public'.

The message can be somewhat confusing, see https://github.com/dotnet/docs/issues/30235 for details.

I suggest using the effective accessibility in place of {1}, and reword it as:

Error BC30389 '{0}' is not accessible in this context because it (or one of the containing symbols) is 'Public'.

Or any other form that's less confusing.

Stackoverflow questions that see this being confused:

https://stackoverflow.com/questions/36713099/why-is-this-public-function-in-a-module-not-accessible https://stackoverflow.com/questions/35346261/new-to-nunit-getting-error-is-not-accessible-in-this-context-because-it-is

Contributor guide