Skip to content

This tool compares two versions of the same assembly, lists the changes to the public API, and suggests an appropriate Semantic Versioning (https://semver.org/) increment.

License

Notifications You must be signed in to change notification settings

pushpay-labs/semantic-versioning-analyzer

Repository files navigation

build test

SemVerAnalyzer SemVerAnalyzer.Abstractions
Nuget Version Nuget Version
Nuget Download Count Nuget Download Count

Semantic Versioning Analyzer

This tool compares two versions of the same assembly (one local and one from a Nuget feed), lists the changes to the public API, and suggests an appropriate Semantic Versioning increment.

By default, it compares the local assembly to a published assembly of the same name on Nuget.org.

Usage

This is published as a dotnet tool. To install:

dotnet tool install SemVerAnalyzer

The command line options are as follows:

  -a, --assembly            Required. The built assembly to test.

  -o, --outputPath          The output file path for the report.

  -c, --config              Required. Path to the configuration file.

  -r, --additional-rules    A path to a single assembly or folder of assemblies which contain additional rules.

  -p, --package-name        If the package name is different than the DLL file name, specify it here.

  --omit-disclaimer         Omits the disclaimer paragraph that appears at the top of the output.

  -h, --include-header      Includes a header with the assembly and package at the top of the output.

  --assume-changes          Assumes that something changed, making Patch the lowest bump rather than None. Default is
                            false.

  --show-changes            Show all changes, even if the version is as expected. Default is false.

  -f, --framework           Indicates the framework from the Nuget package to use as a comparison.

  --help                    Display this help screen.

  --version                 Display version information.

The dotnet command for the tool is analyze-semver. For example,

dotnet analyze-semver -a path/to/MyAssembly.dll -o results.txt -c ./config.json

Configuration

  • settings
    • ruleOverrides - Provides overrides for individual rules (see below).
  • nuget
    • repositoryUrl - The URL to the Nuget feed where the existing assembly is published. Mutually exclusive with packageSource.
    • packageSource - The name of the Nuget package source where the existing assembly is published. Mutually exclusive with repositoryUrl.

Built-in Rules

  • Major (breaking changes)
    • AbstractMethodIsNotOverrideableRule
    • AbstractPropertyIsNotOverrideableRule
    • AbstractEventIsNotOverrideableRule
    • EnumMemberRemovedRule
    • EnumMemberValueChangedRule
    • EventOnInterfaceAddedRule
    • EventRemovedRule
    • MethodOnInterfaceAddedRule
    • MethodRemovedRule
    • NonAbstractMethodHasBecomeAbstractRule
    • NonAbstractPropertyHasBecomeAbstractRule
    • NonAbstractEventHasBecomeAbstractRule
    • PropertyGetterRemovedRule
    • PropertyOnInterfaceAddedRule
    • PropertyOnInterfaceGetterAddedRule
    • PropertyOnInterfaceSetterAddedRule
    • PropertyRemovedRule
    • PropertySetterRemovedRule
    • ProtectedPropertyGetterNotAccessibleRule
    • ProtectedPropertySetterNotAccessibleRule
    • PublicPropertyGetterNotPublicRule
    • PublicPropertySetterNotPublicRule
    • ReferencesMajorBumpedRule
    • TypeRemovedRule
    • VirtualMethodHasBeenSealedRule
    • VirtualPropertyHasBeenSealedRule
    • VirtualEventHasBeenSealedRule
    • VirtualMethodIsNotVirtualRule
    • VirtualPropertyIsNotVirtualRule
    • VirtualEventIsNotVirtualRule
  • Minor (non-breaking additions)
    • EnumMemberAddedRule
    • EventOnConcreteTypeAddedRule
    • InaccessiblePropertyGetterIsNowProtectedRule
    • InaccessiblePropertyGetterIsNowPublicRule
    • InaccessiblePropertySetterIsNowProtectedRule
    • InaccessiblePropertySetterIsNowPublicRule
    • MethodOnConcreteTypeAddedRule
    • PropertyOnConcreteTypeAddedRule
    • PropertyOnConcreteTypeGetterAddedRule
    • PropertyOnConcreteTypeSetterAddedRule
    • ReferencesMinorBumpedRule
    • TypeAddedRule
    • TypeMarkedObsoleteRule
  • Patch
    • ReferencesPatchBumpedRule
    • VirtualMethodHasBeenOverriddenRule
    • VirtualPropertyHasBeenOverriddenRule
    • VirtualEventHasBeenOverriddenRule
    • VirtualMethodIsNoLongerOverriddenRule
    • VirtualPropertyIsNoLongerOverriddenRule
    • VirtualEventIsNoLongerOverriddenRule

Custom Rules

The -r / --additional-rules command switch takes a path to a single assembly or a folder that contains assemblies where additional rules are defined. This can also be set in by the settings.additionalRules configuration setting. The command line switch will override the configuration setting.

A rule is an implementation of IVersionAnalysisRule<T> where T is one of

  • AssemblyDef
  • TypeDef
  • PropertyDef
  • MethodDef
  • EventDef

as defined by the dnlib library. The interface is defined in a separate Nuget package, SemVerAnalyzer.Abstractions, for this purpose.

To help with output, there are also a number of extension methods on the pertinent dnlib types that can generate C#-formatted names for members.

Overriding Rule Severity

The built-in rules are defined with severities as listed above. However, this can be overridden via the settings.ruleOverrides configuration setting.

The value for this setting is an object whose keys are rule names and values are one of

  • Ignore
  • Major
  • Minor
  • Patch

Ignore will prevent the rule from running, while this others will recategorize the rules as configured.

About

This tool compares two versions of the same assembly, lists the changes to the public API, and suggests an appropriate Semantic Versioning (https://semver.org/) increment.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages