-
Notifications
You must be signed in to change notification settings - Fork 4
Add more rules for API compatibility validation #83
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3bda132
Add more rules for API compatibility validation
CptWesley 96cc84f
Update rules/Proj0247.md
CptWesley df5a90a
Update rules/Proj0248.md
CptWesley f94d125
Update rules/Proj0249.md
CptWesley 80f26b7
Update rules/Proj0250.md
CptWesley b64c5b8
Update rules/Proj0251.md
CptWesley 628c879
Update rules/Proj0252.md
CptWesley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| parent: Packaging | ||
| ancestor: Rules | ||
| --- | ||
|
|
||
| # Proj0247: Enable strict mode for package baseline validation | ||
| When ensuring backwards compatibility of the API surface | ||
| of your package, it is adviced to do this in strict mode. | ||
| This helps preventing any unintentional API changes. | ||
|
|
||
| More information can be found [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview), [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/baseline-version-validator) and [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#enablestrictmodeforbaselinevalidation). | ||
|
|
||
| ## Non-compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> | ||
| <EnableStrictModeForBaselineValidation>false</EnableStrictModeForBaselineValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| ## Compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> | ||
| <EnableStrictModeForBaselineValidation>true</EnableStrictModeForBaselineValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --- | ||
| parent: Packaging | ||
| ancestor: Rules | ||
| --- | ||
|
|
||
| # Proj0248: Enable strict mode for package runtime compatibility validation | ||
| When building your package for multiple runtimes it | ||
| is adviced to enable the strict mode of the runtime | ||
CptWesley marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| compatibility validation. | ||
|
|
||
| Note that the default value is `true` and can therefore be omitted. | ||
|
|
||
| More information can be found [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview), [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/compatible-framework-validator) and [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#enablestrictmodeforcompatibletfms). | ||
|
|
||
| ## Non-compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <EnableStrictModeForCompatibleTfms>false</EnableStrictModeForCompatibleTfms> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| ## Compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| parent: Packaging | ||
| ancestor: Rules | ||
| --- | ||
|
|
||
| # Proj0249: Enable strict mode for package framework compatibility validation | ||
| When building your package for multiple target | ||
| frameworks it is adviced to enable the strict | ||
CptWesley marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mode of the framework compatibility validation. | ||
|
|
||
| More information can be found [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview), [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/compatible-framework-in-package-validator) and [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#enablestrictmodeforcompatibleframeworksinpackage). | ||
|
|
||
| ## Non-compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <EnableStrictModeForCompatibleFrameworksInPackage>false</EnableStrictModeForCompatibleFrameworksInPackage> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| ## Compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <EnableStrictModeForCompatibleFrameworksInPackage>true</EnableStrictModeForCompatibleFrameworksInPackage> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| --- | ||
| parent: Packaging | ||
| ancestor: Rules | ||
| --- | ||
|
|
||
| # Proj0250: Generate API compatibility suppression file | ||
| When [package validation](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview) is enabled, it is required to | ||
| provide a [suppression file](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/diagnostic-ids#how-to-suppress) for all differences that | ||
| occur in the API: | ||
| - [Changes between different package versions](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/baseline-version-validator) | ||
| - [Differences between different runtimes (e.g. windows vs unix)](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/compatible-framework-validator) | ||
| - [Differences between different target frameworks (e.g. netstandard2.0 vs net8.0)](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/compatible-framework-in-package-validator) | ||
|
|
||
| This suppression file can be created manually, or automatically generated | ||
| by enabling the `GenerateCompatibilitySuppressionFile` property. It is adviced | ||
| to enable this property in the project file to ensure that file is kept | ||
| up-to-date automatically. | ||
|
|
||
| Additionally, it is adviced to keep changes to the generated file tracked in | ||
| your version control system to ensure any API changes are explicitly included | ||
| in code reviews. | ||
CptWesley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| More information can be found [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview), [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/diagnostic-ids#how-to-suppress) and [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#apicompatgeneratesuppressionfile). | ||
|
|
||
| ## Non-compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <ApiCompatGenerateSuppressionFile>false</ApiCompatGenerateSuppressionFile> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| ## Compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <ApiCompatGenerateSuppressionFile>true</ApiCompatGenerateSuppressionFile> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| --- | ||
| parent: Packaging | ||
| ancestor: Rules | ||
| --- | ||
|
|
||
| # Proj0251: Enable API compatibility attribute checks | ||
| When [package validation](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview) | ||
| is enabled, it is adviced to opt-in to the strict attribute compatibility checks. | ||
CptWesley marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| More information can be found [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview) and [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#apicompatenableruleattributesmustmatch). | ||
|
|
||
| ## Non-compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <ApiCompatEnableRuleAttributesMustMatch>false</ApiCompatEnableRuleAttributesMustMatch> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| ## Compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <ApiCompatEnableRuleAttributesMustMatch>true</ApiCompatEnableRuleAttributesMustMatch> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| parent: Packaging | ||
| ancestor: Rules | ||
| --- | ||
|
|
||
| # Proj0252: Enable API compatibility parameter name checks | ||
| When [package validation](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview) | ||
| is enabled, it is adviced to opt-in to the strict parameter name compatibility checks. | ||
CptWesley marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| While renaming parameters does not directly break runtime compatibility, it can break | ||
| source compatibility when a consuming application uses | ||
| [explicit parameter names](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments#named-arguments) | ||
| when calling one of your methods. | ||
|
|
||
| More information can be found [here](https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/package-validation/overview), [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#apicompatenablerulecannotchangeparametername) and [here](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments#named-arguments). | ||
|
|
||
| ## Non-compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <ApiCompatEnableRuleCannotChangeParameterName>false</ApiCompatEnableRuleCannotChangeParameterName> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| Or: | ||
|
|
||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
|
|
||
| ## Compliant | ||
| ``` xml | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <EnablePackageValidation>true</EnablePackageValidation> | ||
| <ApiCompatEnableRuleCannotChangeParameterName>true</ApiCompatEnableRuleCannotChangeParameterName> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.