-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ApiDiff: Pass an ILog instance to the AssemblySymbolLoader constructor #45807
base: main
Are you sure you want to change the base?
Conversation
test/Microsoft.DotNet.ApiCompatibility.Tests/Rules/AssemblyIdentityMustMatchTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.DotNet.ApiSymbolExtensions.Tests/AssemblySymbolLoaderTests.cs
Outdated
Show resolved
Hide resolved
src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
Outdated
Show resolved
Hide resolved
fd87d94
to
b5dd360
Compare
...Microsoft.DotNet.ApiSymbolExtensions.Tests/Microsoft.DotNet.ApiSymbolExtensions.Tests.csproj
Outdated
Show resolved
Hide resolved
We need to be careful about not adding new warnings to APICompat that didn't exist before. More precisely, APICompat didn't emit diagnostics or warnings, only GenAPI. You might want to make this configurable in the AssemblySymbolLoader ctor. But I would first wait for Eric to reply to the below. @ericstj I just noticed that we have this related code path in APICompat: sdk/src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompatibility/Mapping/AssemblyMapper.cs Lines 126 to 137 in da12057
This goes into the suppression file, i.e. https://github.com/dotnet/aspnetcore/blob/e0e0224d744e6219849538cf9ce5dd3db1ccd658/src/Caching/SqlServer/src/CompatibilitySuppressions.xml#L3-L6 (with a |
Author: Viktor Hofer <[email protected]>
d944529
to
0998075
Compare
...Microsoft.DotNet.ApiSymbolExtensions.Tests/Microsoft.DotNet.ApiSymbolExtensions.Tests.csproj
Outdated
Show resolved
Hide resolved
test/Microsoft.DotNet.ApiSymbolExtensions.Tests/AssemblySymbolLoaderTests.cs
Outdated
Show resolved
Hide resolved
It doesn't feel like it should be in a suppression file, no. Not loading a dependency isn't a problem with the comparison/compatibility, it's a problem with the input to the tool. That said, we do get more granular suppression in the file so it could be more handy in suppressing a particular missing dependency while not suppressing all missing dependencies. |
Co-authored-by: Viktor Hofer <[email protected]>
I wonder if emitting a warning is the right level for missing assemblies. Maybe it would make more sense to treat them as diagnostics? Unsure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but we should first reach consensus regarding the missing assemblies logging when using APICompat. This PR changes that by introducing new warnings, i.e. when doing baseline package validation with missing dependencies on the left side.
The more I think about it, the more I like the idea of treating missing assemblies as diagnostic information.
Would it ever cause us to miss a compatibility check? Suppose the target of a typeforward was missing, and that type broke compat? |
Yes, we had such cases. But if we would now start emitting these as warnings that don't go to the suppression file, there's potential to break repositories that have missing assemblies (i.e. during baseline package validation) and use /warnaserror. But, we only emit the compatibility difference when we perform validation with references. Otherwise, we don't emit the compat difference. If we keep that characteristic then I'm less concerned about the behavioral change. The more I think about, they really shouldn't go into the suppression file. These have been a factor of confusion for others and even me as the owner of the tool. But maybe emitting them as warnings is indeed the right thing to do. Unsure if we ever need a fine-grained suppression mechanism per assembly for these. |
This PR is part of the work needed to create an ApiDiff tool that reuses some of the code from Microsoft.DotNet.GenAPI. The idea is to make the larger PR smaller and make it easier to review: #45389
The purpose of this change is to construct AssemblySymbolLoader instances passing a predefined ILog instance to its constructor which will be necessary later.