-
Notifications
You must be signed in to change notification settings - Fork 540
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
[NUnitLite] fix many warnings #9959
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This project had many warnings similar to 18af3ac: src\Xamarin.Android.NUnitLite\Gui\Instrumentations\TestSuiteInstrumentation.cs(93,5): warning CA1416: This call site is reachable on all platforms. 'Bundle.PutInt(string?, int)' is only supported on: 'Android' 21.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416) Basically, every call to an Android API emits this warning. This analyzer relies on `AssemblyInfo.cs` to determine the `$(SupportedOSPlatformVersion)` value. `$(GenerateAssemblyInfo)=false` appears to break this analyzer! Since `src-ThirdParty\NUnitLite\AssemblyInfo.cs` sets some of these values, we can opt out of specifically: <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> And then the `CA1416` warnings go away. I also fixed some trimmer warnings: src-ThirdParty\NUnitLite\Api\ExpectedExceptionData.cs(130,36): warning IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The parameter 'fixtureType' of method 'NUnit.Framework.Api.ExpectedExceptionData.GetExceptionHandler(Type)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. src-ThirdParty\NUnitLite\Constraints\XmlSerializableConstraint.cs(56,30): warning IL2026: Using member 'System.Xml.Serialization.XmlSerializer.XmlSerializer(Type)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Members from serialized types may be trimmed if not referenced directly. src-ThirdParty\NUnitLite\Constraints\XmlSerializableConstraint.cs(56,30): warning IL3050: Using member 'System.Xml.Serialization.XmlSerializer.XmlSerializer(Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. XML serializer relies on dynamic code generation which is not available with Ahead of Time compilation. src-ThirdParty\NUnitLite\ListMapper.cs(57,29): warning IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. Note that I could simply remove `ListMapper.cs`, as it is not used. I did not fix *all* of the trimmer warnings, as there are so many more.
dellis1972
approved these changes
Mar 25, 2025
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 ok, lots of build failures thought .... 🤔
I think
I reran the others. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This project had many warnings similar to 18af3ac:
Basically, every call to an Android API emits this warning.
This analyzer relies on
AssemblyInfo.cs
to determine the$(SupportedOSPlatformVersion)
value.$(GenerateAssemblyInfo)=false
appears to break this analyzer!Since
src-ThirdParty\NUnitLite\AssemblyInfo.cs
sets some of these values, we can opt out of specifically:And then the
CA1416
warnings go away.I also fixed some trimmer warnings:
Note that I could simply remove
ListMapper.cs
, as it is not used.I did not fix all of the trimmer warnings, as there are so many more.