altcode.gendarme-tool
2024.6.28.12460
dotnet tool install --global altcode.gendarme-tool --version 2024.6.28.12460
dotnet new tool-manifest
dotnet tool install --local altcode.gendarme-tool --version 2024.6.28.12460
#tool dotnet:?package=altcode.gendarme-tool&version=2024.6.28.12460
nuke :add-package altcode.gendarme-tool --version 2024.6.28.12460
altcode.gendarme/altcode.gendarme-tool
A Mono.Gendarme fork, built against a recent Mono.Cecil version, one that can load assemblies built with current compilers.
Features
- Can load .net core assemblies
- Will search the nuget cache for dependencies, though this can take some time as an alternative to using
dotnet publishto get all the code you want to analyse in one place. - Updated for modern C# dialect e.g. allow discard
_as a variable name - Bug fixes and updates for current compiler generated IL
- Will search the nuget cache for dependencies, though this can take some time as an alternative to using
- Will load debug information from embedded symbols or actual
.pdbfiles if available even on non-Windows platforms.- The main impact is that the
AvoidLongMethodsRuleworks by LoC and not IL against .net core code on all platforms.
- The main impact is that the
- Depending whether the Framework or dotnet tool version is used, the results may differ when faced with the same assembly, because of the different runtime being consulted
- e.g. several types marked
[Serializable]in the Framework are not so marked atdotnet, so serialization rules will give different answers
- e.g. several types marked
- Because they use obsolescing functions not present in
netstandard2.0the followingGendarme.Rules.Security.Casrules are only present in the Framework tool build, under theObsolete.Rules.Security.Casname:AddMissingTypeInheritanceDemandRuleDoNotExposeMethodsProtectedByLinkDemandRuleDoNotReduceTypeSecurityOnMethodsRuleSecureGetObjectDataOverridesRule
- The obsolete
Gendarme.Rules.Portability.MonoCompatibilityReviewRuleis not implemented in this fork. DefineAZeroValueRuledoes not trigger for non-int32 enums that have a suitably typed zero value. This rule should not also be doing the job ofEnumsShouldUseInt32Rule- Due to IL changes
UseIsOperatorRulehas been tuned to avoid false positives at the cost of missing some failure cases - New rules/categories
AltCode.Rules.General.AvoidAssemblySemanticVersionMismatchRuleto insist that the API contract (major, minor, and optionally build if defined for the assembly) match, but the lesser facets, revision and possibly build are free.AltCode.Rules.General.JustifySuppressionRuleto check theJustificationproperty onSuppressMessageattributeAltCode.Rules.General.PreferStrongNamedAssembliesRuleto replace deprecated/withdrawn FxCop rule Microsoft.Design#CA2210AltCode.Rules.PowerShell.UseOnlyStandardVerbsRuleto replace "Microsoft.PowerShell#PS1001:UseOnlyStandardVerbs"AltCode.Rules.PowerShell.DefineCmdletInTheCorrectNamespaceRuleto replace "Microsoft.PowerShell#PS1011:DefineCmdletInTheCorrectNamespace"Gendarme.Rules.Serialization.RelaxedMarkAllNonSerializableFieldsRuleto ignore F# compiler generated closuresGendarme.Rules.Smells.RelaxedAvoidCodeDuplicatedInSameClassRuleto ignore some trivial cases e.g. argument null checks
- Reinstated rules
Gendarme.Rules.BadPractice.AvoidNullCheckWithAsOperatorRuleGendarme.Rules.BadPractice.DoNotDecreaseVisibilityRuleGendarme.Rules.Correctness.DeclareEventsExplicitlyRuleGendarme.Rules.Design.DoNotDeclareSettersOnCollectionPropertiesRule(excluding thePermissionSetexemption)Gendarme.Rules.Exceptions.DoNotThrowInNonCatchClausesRuleGendarme.Rules.Globalization.PreferIFormatProviderOverrideRuleGendarme.Rules.Globalization.PreferStringComparisonOverrideRule
- In the text output, include a specimen global suppression attribute for each issue, for convenience when dealing with remaining intractable issues e.g. arising from code generation
- While
Scopeis not heeded by the Gendarme process, it's there to placate other consumers (which will ignore the foreign rule); the comment indicates the corresponding object type within the Gendarme analysis in case they should ever be out of line. - The syntax and punctuation of the
Targetwith regards to nested types and special names is as Gendarme expects, which differs somewhat from FxCop in annoying details - The emitted section looks like this:
- While
Global Suppression Attribute:
[<assembly: SuppressMessage("Gendarme.Rules.Correctness",
"MethodCanBeMadeStaticRule",
Scope = "member", // MethodDefinition
Target = "ParameterNamesShouldMatch.Handler::ShowMessage(a,System.String)",
Justification = "")>]
Known Issues
Not all the classic Gendarme unit tests currently pass. In the main, these failures are due to the Roslyn compiler producing different IL than the original C# compiler did. In production these will typically manifest as false negatives.
Changes made for F# support
The F# compiler generates a large amount of code that does not conform to these rules, particularly with closures. A full list for the most recent release is presented here.
Badges
| Build | GitHub |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 2024.6.28.12460 | 730 | 6/28/2024 |
| 2023.12.27.19054 | 571 | 12/27/2023 |
| 2023.8.26.15512 | 490 | 8/26/2023 |
| 2023.1.22.12221 | 666 | 1/22/2023 |
| 2023.1.21.13293 | 489 | 1/21/2023 |
| 2022.12.6.7345 | 627 | 12/6/2022 |
| 2022.5.17.8260 | 2,210 | 5/17/2022 |
This build from https://github.com/SteveGilham/Gendarme/tree/9574e5d18ce3e5295b406ac32e3cb29bbf5e6685
2024.6.28.12460
• Handle injected "[Embedded]" attributes more generally by ignoring them for AttributeArgumentsShouldHaveAccessorsRule
For previous releases, go here -- https://github.com/SteveGilham/Gendarme/blob/trunk/ReleaseNotes%20-%20Previously.md