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

code analysis throws AD0001 and does not report the correct error #7561

Open
vsfeedback opened this issue Feb 4, 2025 · 0 comments
Open

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Hello
One typical code error triggers the correct message as seen in Output
3>D:\JMB\System\VB.net\Net8_DLLs_Tests\JMF_Test_Globals_JMF_Test_Globals.vb(70,19): error BC30266: 'Public Overrides Sub mgrs_newdispose([eND] As jmcore_globals.ND_enum)' cannot override 'Protected MustOverride Sub mgrs_NewDispose([eND] As jmcore_globals.ND_enum)' because they have different access levels.
But in the Error List tab a rather confusing message appears and the error is not reported.
Analyzer 'Microsoft.CodeAnalysis.Diagnostics.VisualBasic.VisualBasicCompilerDiagnosticAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Reported diagnostic 'BC30266' has a source location in file 'D:\JMB\System\VB.net\Net8_DLLs\JMCore\sources JMCore\ZMgrs.vb', which is not part of the compilation being analyzed. (Parameter 'diagnostic')'.
Exception occurred with following context:
Compilation: JMF_Test_PJ
SyntaxTree: D:\JMB\System\VB.net\Net8_DLLs_Tests\JMF_Test_Globals_JMF_Test_Globals.vb

System.ArgumentException: Reported diagnostic 'BC30266' has a source location in file 'D:\JMB\System\VB.net\Net8_DLLs\JMCore\sources JMCore\ZMgrs.vb', which is not part of the compilation being analyzed. (Parameter 'diagnostic')
at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalysisContextHelpers.VerifyDiagnosticLocationInCompilation(String id, Location location, Compilation compilation)
at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalysisContextHelpers.VerifyDiagnosticLocationsInCompilation(Diagnostic diagnostic, Compilation compilation)
at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalysisContextHelpers.VerifyArguments(Diagnostic diagnostic, Compilation compilation, Func3 isSupportedDiagnostic, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Diagnostics.SemanticModelAnalysisContext.ReportDiagnostic(Diagnostic diagnostic) at Microsoft.CodeAnalysis.Diagnostics.CompilerDiagnosticAnalyzer.CompilationAnalyzer.ReportDiagnostics(ImmutableArray1 diagnostics, Action1 reportDiagnostic, Func2 locationFilter, ImmutableDictionary2 properties) at Microsoft.CodeAnalysis.Diagnostics.CompilerDiagnosticAnalyzer.CompilationAnalyzer.AnalyzeSemanticModel(SemanticModelAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)

Suppress the following diagnostics to disable this analyzer: AD0001, BC2001, .....very long list

If you are not aware of this error it may be quite misleading.
In my case this happens if a routine declared with "protected" in the base class is overridden with a routine declared Public in the inheriting class
in the inheriting class
Overrides Sub mgrs_newdispose([eND] As ND_enum)
Throw New NotImplementedException() ' there is no sub project in this case (only JMCore)
End Sub
and in the base class
Protected MustOverride Sub mgrs_NewDispose([eND] As ND_enum) Implements IMgr_DLLorPJ.mgrs_NewDispose
This error has been here for a long time.
Thanks in advance

Windows 11 up to date, Visual Studio Preview up to date, Net 8.0. Happens on all VS releases


Original Comments

Feedback Bot on 2/3/2025, 01:13 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 2/3/2025, 07:03 AM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.

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

No branches or pull requests

1 participant