[build] Ignore CA1305 in more projects #8110
Merged
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.
Commit 04e4bb1 turned
CA1305
into a build error for projects in thesrc
directory, however the .NET analyzers that detect this issue onlyrun by default on projects targeting .NET 5.0 or later. Sources that
target
netstandard2.0
(including our build tasks) contain instances ofCA1305
that should be fixed, but these errors weren't being reportedin our regular builds.
Our nightly build managed to catch some of these issues, as this build
set an MSBuild property that would cause our sources to import the FxCop
NuGet package.
FxCop is deprecated, and it should be replaced by using the first-party
.NET analyzers. These analyzers can be enabled for projects with older
target frameworks by setting the
$(EnableNETAnalyzers)
propertyto
true
. This property is now set to true for all build types (pr,CI, nightly) and projects in xamarin-android.
After enabling .NET analyzers on projects with older target frameworks,
the following projects needed to suppress
CA1305
warnings as errors tofix the regular and nightly builds:
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj
src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj
We should try to address the
CA1305
issues in these non-test projectsin a future PR.