You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DynamicallyAccessedMembersAnalyzer throws an internal exception due to source location outside compilation #109352
In enabling the AOT readiness analyzers, the MessagePack codebase produces a lot of warnings. Among them is an AD0001 warning about a failed analyzer. See Exceptions section for details.
To Reproduce
git clone https://github.com/MessagePack-CSharp/MessagePack-CSharp.git
cd MessagePack-CSharp
git checkout dotnet/sdk/bug44120repro
.\MessagePack.sln
Inspect the error list, filtering to AD0001 entries.
Exceptions (if any)
Analyzer 'ILLink.RoslynAnalyzer.DynamicallyAccessedMembersAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Reported diagnostic 'IL2075' has a source location in file 'Q:\source\MessagePack-CSharp\src\MessagePack.Annotations\Attributes.cs', which is not part of the compilation being analyzed. (Parameter 'diagnostic')'.
Exception occurred with following context:
Compilation: MessagePack
ISymbol: BuildCustomFormatterField (Method)
System.ArgumentException: Reported diagnostic 'IL2075' has a source location in file 'Q:\source\MessagePack-CSharp\src\MessagePack.Annotations\Attributes.cs', 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, Func`3 isSupportedDiagnostic, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.ReportDiagnostic(Diagnostic diagnostic)
at ILLink.RoslynAnalyzer.DynamicallyAccessedMembersAnalyzer.<>c.<Initialize>b__8_1(OperationBlockAnalysisContext context)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)
Further technical details
Include the output of dotnet --info
The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
Warnings don't show up for me until I open source files. When I open DynamicObjectResolver.cs and MessagePack.Annotations\Attributes.cs, with no build I still can't get the AD0001. Which files do you have open when you get the AD0001 error? Or do you have a setting that turns on analysis on for unopened files?
@jtschuster did you end up getting any more insight into this? If you still have a repro handy it would be great if you could share it for future reference.
I wasn't able to find the root cause. I haven't checked recent builds, but the repro in the original message worked once I set VS to run analysis on unopened files.
Activity
JulieLeeMSFT commentedon Nov 6, 2024
CC @amanasifkhalid.
JulieLeeMSFT commentedon Nov 6, 2024
@agocke, please see if this is an ILLInk related issue.
13 remaining items
jtschuster commentedon Nov 14, 2024
Warnings don't show up for me until I open source files. When I open
DynamicObjectResolver.csandMessagePack.Annotations\Attributes.cs, with no build I still can't get the AD0001. Which files do you have open when you get the AD0001 error? Or do you have a setting that turns on analysis on for unopened files?AArnott commentedon Nov 14, 2024
I definitely have this setting in my IDE.
jtschuster commentedon Nov 14, 2024
Thank you, that did it, I can repro now. Now to investigate why..
sbomer commentedon Jun 10, 2025
@jtschuster did you end up getting any more insight into this? If you still have a repro handy it would be great if you could share it for future reference.
jtschuster commentedon Jun 10, 2025
I wasn't able to find the root cause. I haven't checked recent builds, but the repro in the original message worked once I set VS to run analysis on unopened files.
Don't attach code-fix locations from outside the analyzed compilation (…