- Handle injected "[Embedded]" attributes more generally by ignoring them for AttributeArgumentsShouldHaveAccessorsRule
- Ignore badly formed attribute types ([Nullable] and [Embedded]) injected by the C# compiler
- Ignore badly formed types injected by the dotnet 7.0.400 and 8.0pv FSharp compiler ([], & enum DynamicallyAccessedMemberTypes)
- [BUGFIX] Fix environment dependent NRE in
AvoidUncalledPrivateCodeRule
(and others) - [BUGFIX] Fix possible false -ves wrt tasks in
EnsureLocalDisposalRule
- Exempt
Task
andTask<'T>
fromEnsureLocalDisposalRule
as they generally should not be disposed manually. - Remove the "no arguments means no error" hack from
InstantiateArgumentExceptionCorrectlyRule
to align its behaviour with FxCop'sCA2208:InstantiateArgumentExceptionsCorrectly
; only with the added trick of looking at the top-level user-declared method in case of compiler generated functions (e.g. inyield
based iterators)
- [BUGFIX] Address some context dependent instances of assembly resolution failure
- Adjust
DoNotAssumeIntPtrSizeRule
to allow for compiler changes at dotnet 7.0. There will still be false negatives as casts involvingIntPtr
are now inlined, rather than going toop_Explicit
- Fix false positives for
DoNotThrowInNonCatchClausesRule
fortry/when/catch
cases thatthrow
from thecatch
- Fix some false negatives for
AvoidSwitchStatementsRule
(where the switch is on astring
value) - Fix false positives for
DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule
andAvoidUnneededUnboxingRule
associated with changes in F# exception handling
- First stable release
- Make a heuristic fix for the changed IL that meant a test failure for
AvoidUnnecessarySpecializationRule
- code that was IL_0001: ldarga.s x/ IL_0003: constrained. !!T (stack unchanged) is now IL_0001: ldarg.1/IL_0002: box !!T which pops the loaded value and pushes the boxed copy, so treat ldarg+box as a unit.
- Make heuristic fixes for
CheckParametersNullityInVisibleMethods
-- also related to boxing generics; and cases of different choices of comparison operation - Propagate the checks for the changed null comparison IL to
ProtectCallToEventDelegatesRule
- Fix false negatives in
DelegatesPassedToNativeCodeMustIncludeExceptionHandlingRule
- Fix false negative in
TestNativeFieldsArray
-- extended checks for new changed IL
- [NEW RULE]
AltCode.Rules.General.AvoidAssemblySemanticVersionMismatchRule
to 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. - Revive Correctness rule
DeclareEventsExplicitlyRule
- Update for modern C# dialect e.g. allow discard
_
as a variable name - Fix
PreferIFormatProviderOverrideRule
andPreferStringComparisonOverrideRule
to spot more than just the first instance of any given method with a preferred override - In
AvoidMethodsWithSideEffectsInConditionalCodeRule
, considerSystem.Array.Empty<T>()
to be pure. AvoidUninstantiatedInternalClassesRule
checks ifinternal
attribute types are used in the assembly, and counts those as instantiation- Include changes from the upstream repo
- Add more heuristics to
DoNotHardcodePathsRule
- Tune the severity and confidence levels of
AvoidUnnecessarySpecializationRule
and the "avoid duplicated code" rules according to context - Test a wider set of use cases in
DoNotUseLockedRegionOutsideMethodRule
- Add more heuristics to
- Reinstate
Gendarme.Rules.Security.Cas.DoNotExposeFieldsInSecuredTypeRule
, mistakenly deleted - New rules
AltCode.Rules.General.PreferStrongNamedAssembliesRule
to replace deprecated/withdrawn FxCop rule Microsoft.Design#CA2210:AssembliesShouldHaveValidStrongNamesAltCode.Rules.PowerShell.UseOnlyStandardVerbsRule
to replace "Microsoft.PowerShell#PS1001:UseOnlyStandardVerbs"
- [net472] Reinstate the obsolescing code access security rules as the assembly
Obsolete.Rules.Security.Cas.dll
; this covers rulesAddMissingTypeInheritanceDemandRule
DoNotExposeMethodsProtectedByLinkDemandRule
DoNotReduceTypeSecurityOnMethodsRule
SecureGetObjectDataOverridesRule
- New rule categories
AltCode.Rules.General
for general purpose rules, starting withJustifySuppressionRule
to check theJustification
sproperty onSuppressMessage
attributeAltCode.Rules.PowerShell
for re-implementing the old Microsoft PowerShell FxCop rules, starting withDefineCmdletInTheCorrectNamespaceRule
to check the naming convention
- Fix the Gendarme.Rules.Gendarme.UseCorrectSuffixRule to ignore unutterable classes in namespaces starting with "
<StartupCode$
". - Fix where the Gendarme.Rules.Globalization.SatelliteResourceMismatchRule reads bitmaps from resource assemblies, providing a dummy type as needed.
- Fix false positives in globalization rules
PreferIFormatProviderOverrideRule
andPreferStringComparisonOverrideRule
in a net6.0-only environment
- Fix intermittent/environmentally dependent bugs in --
- Globalization rules
PreferIFormatProviderOverrideRule
andPreferStringComparisonOverrideRule
- Correctness rule
BadRecursiveInvocationRule
- Globalization rules
net40
build removed; the Framework tool now uses sharednetstandard2.0
assemblies with anet472
executable. This also means that the stale code access security rules are now removed --AddMissingTypeInheritanceDemandRule
DoNotExposeMethodsProtectedByLinkDemandRule
DoNotReduceTypeSecurityOnMethodsRule
SecureGetObjectDataOverridesRule
- In the text output, include a specimen global suppression attribute for each issue (F# syntax, ready to copy and paste; for other languages, tweak the
[<>]
part of the declaration). This is for convenience when dealing with intractable issues e.g. arising from code generation- While
Scope
is 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
Target
with regards to nested types and special names is as Gendarme expects, which differs somewhat from FxCop in annoying details
- While
Global Suppression Attribute:
[<assembly: SuppressMessage("Gendarme.Rules.Correctness",
"MethodCanBeMadeStaticRule",
Scope = "member", // MethodDefinition
Target = "ParameterNamesShouldMatch.Handler::ShowMessage(a,System.String)",
Justification = "")>]
- Fixes
DoNotLockOnThisOrTypesRule
for current C# compiler IL generation - Reenable several rules omitted in previous builds
- bad practice rules
AvoidNullCheckWithAsOperatorRule
andDoNotDecreaseVisibilityRule
- design rule
DoNotDeclareSettersOnCollectionPropertiesRule
(excluding thePermissionSet
exemption) - exception rule
DoNotThrowInNonCatchClausesRule
- globalization rules
PreferIFormatProviderOverrideRule
andPreferStringComparisonOverrideRule
- bad practice rules
Issues found in use
- Don't apply DoNotDeclareVirtualMethodsInSealedTypeRule to F# closures in addition to existing type exemptions
Fixes/updates
- net50 compatibility
- Fix possible type reference failure with F# code
- Enable
ProvideValidXmlStringRule
andProvideValidXpathExpressionRule
for .net standard - Fix
ProvideCorrectArgumentsToFormattingMethodsRule
andReviewLinqMethodRule
for Roslyn - Avoid false positives in
UseIsOperatorRule
for Roslyn - Because they use obsolescing functions not present in
netstandard2.0
the followingGendarme.Rules.Security.Cas
rules are not implemented in the global tool version (so if this is relevant to you, use the .net Framework build):AddMissingTypeInheritanceDemandRule
DoNotExposeMethodsProtectedByLinkDemandRule
DoNotReduceTypeSecurityOnMethodsRule
SecureGetObjectDataOverridesRule
- The obsolete
Gendarme.Rules.Portability.MonoCompatibilityReviewRule
has been removed.
Issues found in use
- Don't apply ParameterNamesShouldMatchOverridenMethodRule to cases where the base method has a null or empty parameter name (e.g. F# interfaces)
Issues found in use
- Notice zero values in non-int32 enums
- Skip types called
<PrivateImplementationDetails>
Issues found in use
- Improve the assembly resolution to
- check more cases where type hierarchies are being explored
- In
PreferLiteralOverInitOnlyFieldsRule
. a field initialization may be by reference -- ensure it is resolved before treating it directly.
F# niggles part 7
- Adapt
UseCorrectCasingRule
to be compatible withFSharpLint
for F# code - Add a
RelaxedMarkAllNonSerializableFieldsRule
which ignores F# types with@
in the name, keeping the full-strength version for cases where serializing a closure is intentional.
- Improve the assembly resolution to
- distinguish different versions of the same assembly
- look in the nuget cache if the assembly isn't local (means that .net core code needn't be published, at the cost of the extra time taken to search the cache.)
[BUGFIX] another fix needed for the tool, despite it working for the operational test.
[BUGFIX] Fix up and operationally test the gendarme global tool as part of the build
F# niggles part 6
- [BUGFIX] The extension method
IsEventCallback
would throw NRE for certain generic F# types - For
AvoidLargeClassesRule
, ignoreFSharpFunc
andFSharpTypeFunc
valued fields in generated types with@
in their names; treat them as methods in the type instead. - For
AvoidDeepNamespaceHierarchyRule
, ignore F# generated namespaces of the form<StartupCode$a-b-c-d>.$.NETFramework,Version=...
- For
AvoidRepetitiveCastsRule
, ignore F#is
thenas
of anonymous temporaries (often happens inmatch
expressions on sum types) - Report the owning assembly of the defect target, always (disambiguates when a source file is shared bewteen projects in the same build).
- In the unhandled exception message, own this fork.
- Building on VS2019 for .net4.0 and .netcore2.1+
- Now available as a dotnet global tool in package
altcode.gendarme-tool
F# niggles part 5
- Exempt generated types with "@" in the name from
AvoidMethodWithUnusedGenericTypeRule
- Exempt the field accessors of F# types (usually bypassed by the compiler by code that goes direct to the backing field) from
AvoidUncalledPrivateCodeRule
- Allow for F# extension properties (
TypeName.get_...
andTypeName.set_...
) and for generated parameter names of the form_arg...
inAvoidNonAlphanumericIdentifierRule
- Consider F# extension methods/properties to be object-bound rather than module bound for
UseCorrectCasingRule
- Add a heuristic to recognise F# compiler generated disposal after a
use
inEnsureLocalDisposalRule
- Add a
RelaxedAvoidCodeDuplicatedInSameClassRule
, which looks for patterns aligning with visible sequence points, and excludes patterns containingthrow new ArgumentNullException(...)
F# niggles part 4
- Exempt generated types with
@
in their names fromAvoidUnnecessarySpecializationRule
,AvoidSpeculativeGeneralityRule
andMethodCanBeMadeStaticRule
- Exempt F# placeholder arguments
_
(compiled to_arg...
) fromUseCorrectCasingRule
- Exempt module-bound functions from
ConsiderConvertingMethodToPropertyRule
- Exempt fields and constructors of records from
RemoveDependenceOnObsoleteCodeRule
; accessors will still be caught but can be[SuppressMessage]
d as needed - Take account of F#'s habit of making a virtual call to the base type constructor in object types constructors.
- Exempt F# code in modules, or where a
match
could equally be anif
fromAvoidSwitchStatementsRule
,match
being idiomatic and occasionally just happening to be on an explicit integral type - Exempt property backing fields for code like
member val LocalSource = false with get, set
fromAvoidUnneededFieldInitializationRule
- Exempt union cases (unsealed but not likely to be inherited) from
AvoidUnsealedUninheritedInternalTypeRule
F# niggles part 3
- For the purposes of generic parameter names, having the F# [CompilationMapping] attribute on the type is taken to detect F# code
- Even if a union type is [Obsolete] don't bother telling us its cases and case constructors depend on it.
- In F# code (assumes FSharp.Core referenced) then allow single lower-case letter generic types
- Exempt methods of F# generated types with
@
in the name fromParameterNamesShouldMatchOverriddenMethodRule
- Exempt match on union types from
AvoidSwitchStatementsRule
- Exempt F# generated types with
@
in the name fromUseCorrectPrefixRule
,VariableNamesShouldNotMatchFieldNamesRule
andUseCorrectCasingRule
- Exempt generated abstract closure types from
AbstractTypesShouldNotHavePublicConstructorsRule
- Exempt constructors of record types, or generated types with
@
in the name, fromAvoidLongParameterListsRule
- Module-bound functions should be camel-cased in the
UseCorrectCasingRule
F# niggles part 2
- Explicitly exempt the
get_
andset_
prefixes of getter and setter methods from theAvoidNonAlphanumericIdentifierRule
since that was not already a thing. - Make
AvoidUnneededUnboxingRule
not applicable to[CompilerGenerated]
functions (e.g. Union caseCompareTo
) - Exempt debugger-related generated types related to union types from
AvoidUnsealedUninheritedInternalTypeRule
andUseCorrectCasingRule
- Exempt getter and setter methods from
ConsiderConvertingMethodToPropertyRule
(well, duh!) - Exempt types with only fully
[CompilerGenerated]
Equals
andCompareTo
methods fromImplementIComparableCorrectlyRule
; also explicitly exempt record types
F# niggles first pass
- Fix
AvoidMultidimensionalIndexerRule
for F# generated parameterless methods calledget_Item
- Fix comparison of nested type names in parameters against supplied types
- Ignore [CompilerGenerated] methods for
AvoidSwitchStatementsRule
andCheckParametersNullityInVisibleMethodsRule
- Ignore [CompilerGenerated] fields and methods for
VariableNamesShouldNotMatchFieldNamesRule
- Ignore
<StartupCode$
names inUseCorrectCasingRule
- Ignore generated types containg
@
in their names forAvoidUnsealedUninheritedInternalTypesRule
- Ignore the
Tags
generated type inside union types forAvoidVisibleConstantFieldRule
- Replace the symbol reader extension with the more modern and general one from AltCover
- Static-link the FSharp.Core library into the symbol reader extension.
- Build the code as of commit b45416d516b18e77c1e73be31649bb298b1c6652 (24-Oct-2016) against Cecil 0.11.1 and NUnit 2.7.1 using VS2013 (pre-Roslyn compiler)
- Unit test failures for rules
- Gendarme.Rules.Performance\Test\AvoidUnnecessaryOverridesTest
- Gendarme.Rules.Design\Test\ProvideTryParseAlternativeTest
- Gendarme.Rules.Serialization\Test\CallBaseMethodsOnISerializableTypesTest
- Gendarme.Rules.Correctness\Test\ProvideCorrectRegexPatternTest
- Gendarme.Rules.Concurrency\Test\ProtectCallToEventDelegatesTest
- Gendarme.Rules.Exceptions\Test\UseObjectDisposedExceptionTest
- Unit test failure for Gendarme.Framework.Helpers\StackEntryAnalysisTest
- Do not rely on the failed rules.
- Should work against .netstandard/.netcore binaries (you will need to
dotnet publish
to put any relevant dependencies in the same folder for Gendarme to inspect for inheritance -- especially so for F# code)