From a18dcbb97c6a1e25df61b527d3b4611fc19ff8ff Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 11:32:21 -0800 Subject: [PATCH 01/18] Update script --- .azure/pipelines/ci.yml | 3 +++ eng/scripts/CodeCheck.ps1 | 5 +++-- src/Caching/SqlServer/src/PublicAPI.Shipped.txt | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index f4cb66affec1..cdd968fb0ab4 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -128,6 +128,9 @@ stages: steps: - powershell: ./eng/scripts/CodeCheck.ps1 -ci $(_InternalRuntimeDownloadArgs) displayName: Run eng/scripts/CodeCheck.ps1 + env: + PULLREQUEST_SOURCEBRANCH: $(System.PullRequest.SourceBranch) + PULLREQUEST_TARGETBRANCH: $(System.PullRequest.TargetBranch) artifacts: - name: Code_Check_Logs path: artifacts/log/ diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 078c34bc9ad8..a86e6fc9cca6 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -194,8 +194,9 @@ try { Write-Host "Checking for changes to API baseline files" # Retrieve the set of changed files compared to main - $commitSha = git rev-parse HEAD - $changedFilesFromMain = git --no-pager diff origin/main...$commitSha --ignore-space-change --name-only --diff-filter=ar + $targetBranch = $env:PULLREQUEST_TARGETBRANCH + $sourceBranch = $env:PULLREQUEST_SOURCEBRANCH + $changedFilesFromMain = git --no-pager diff $targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() if ($changedFilesFromMain) { diff --git a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt index 07f76fca9e9b..67145bcac3ea 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt @@ -25,3 +25,5 @@ Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void ~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection + +TEST From 9fcd1fdb3ceccbe68e61f1d3f3ea379ea66ee1fa Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 11:39:34 -0800 Subject: [PATCH 02/18] Documentation feedback --- docs/APIBaselines.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index f44598af9b86..d7543a0e3e8b 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -6,8 +6,24 @@ This document contains information regarding API baseline files and how to work When creating a new implementation (i.e. src) project, it's necessary to manually add API baseline files since API baseline are enabled by default. If the project is a non-shipping or test only project, add `false` to the project to disable these checks. To add baseline files to the project: -1. Copy eng\PublicAPI.empty.txt to the project directory and rename it to PublicAPI.Shipped.txt -1. Copy eng\PublicAPI.empty.txt to the project directory and rename it to PublicAPI.Unshipped.txt +1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Shipped.txt` +1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Unshipped.txt` +1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project +1. `{directory containing relevant *.slnf}\startvs.cmd` +1. F6 # or whatever your favourite build gesture is +1. Click on a RS0016 (or whatever) error +1. Right click in editor on underscored symbol or go straight to the “quick fix” icon to its left. Control-. also works. +1. Choose “Add Blah to public API” / “Fix all occurrences in … Solution” +1. Click Apply +2. F6 # again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon) +3. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed + `[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]` + or + `[SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]` + +More information available in +- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md +- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md ## PublicAPI.Shipped.txt @@ -47,4 +63,4 @@ Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Dis ## Updating baselines after major releases -TODO \ No newline at end of file +This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi. The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt \ No newline at end of file From bbaadea84b5606f97d8dc7ea6fa1e08220b51dd8 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 11:59:12 -0800 Subject: [PATCH 03/18] nit --- docs/APIBaselines.md | 4 ++-- eng/scripts/CodeCheck.ps1 | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index d7543a0e3e8b..7389c84d9bdb 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -15,8 +15,8 @@ When creating a new implementation (i.e. src) project, it's necessary to manuall 1. Right click in editor on underscored symbol or go straight to the “quick fix” icon to its left. Control-. also works. 1. Choose “Add Blah to public API” / “Fix all occurrences in … Solution” 1. Click Apply -2. F6 # again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon) -3. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed +1. F6 # again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon) +1. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed `[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]` or `[SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]` diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index a86e6fc9cca6..303b247f1ecf 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -191,11 +191,12 @@ try { } } - Write-Host "Checking for changes to API baseline files" - - # Retrieve the set of changed files compared to main $targetBranch = $env:PULLREQUEST_TARGETBRANCH $sourceBranch = $env:PULLREQUEST_SOURCEBRANCH + + # Retrieve the set of changed files compared to main + Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" + $changedFilesFromMain = git --no-pager diff $targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() From a2f5107b48af2e6886746ae18fd33e9ea3168c78 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 12:02:52 -0800 Subject: [PATCH 04/18] Add note for what files to check --- eng/scripts/CodeCheck.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 303b247f1ecf..a719b2f9530a 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -202,6 +202,7 @@ try { if ($changedFilesFromMain) { foreach ($file in $changedFilesFromMain) { + # Check for changes in Shipped in dev branches and both Shipped and Unshipped in servicing branches if ($file -like '*PublicAPI.Shipped.txt') { $changedAPIBaselines.Add($file) } From 74f4c5aa9a4dd04a219a4bbbc66903f96d630133 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 13:18:44 -0800 Subject: [PATCH 05/18] Minor fixup for testing --- eng/scripts/CodeCheck.ps1 | 2 +- src/Caching/SqlServer/src/PublicAPI.Shipped.txt | 3 --- src/Caching/SqlServer/src/PublicAPI.Unshipped.txt | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index a719b2f9530a..1ab69fce8d8d 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -197,7 +197,7 @@ try { # Retrieve the set of changed files compared to main Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" - $changedFilesFromMain = git --no-pager diff $targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar + $changedFilesFromMain = git --no-pager diff origin/$targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() if ($changedFilesFromMain) { diff --git a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt index 67145bcac3ea..99c76cbcec82 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt @@ -24,6 +24,3 @@ Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void -~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection - -TEST diff --git a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt index ab058de62d44..ebe087a2b9b1 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection From 63aba98d8a684a11aaec938705157f8f9a933313 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 14:06:26 -0800 Subject: [PATCH 06/18] Update CodeCheck.ps1 --- eng/scripts/CodeCheck.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 1ab69fce8d8d..2b4b8e6951f1 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -197,7 +197,7 @@ try { # Retrieve the set of changed files compared to main Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" - $changedFilesFromMain = git --no-pager diff origin/$targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar + $changedFilesFromMain = git --no-pager diff origin/$targetBranch...origin/$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() if ($changedFilesFromMain) { From 1bc17acc8511ec6f39d1fe83404bb4cf0dd3772b Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 16:40:25 -0800 Subject: [PATCH 07/18] Revert test --- eng/scripts/CodeCheck.ps1 | 6 +++++- src/Caching/SqlServer/src/PublicAPI.Shipped.txt | 1 + src/Caching/SqlServer/src/PublicAPI.Unshipped.txt | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 2b4b8e6951f1..b283427d99c4 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -202,10 +202,14 @@ try { if ($changedFilesFromMain) { foreach ($file in $changedFilesFromMain) { - # Check for changes in Shipped in dev branches and both Shipped and Unshipped in servicing branches + # Check for changes in Shipped in all branches if ($file -like '*PublicAPI.Shipped.txt') { $changedAPIBaselines.Add($file) } + # Check for changes in Unshipped in servicing branches + if ($targetBranch -like 'release*' && $file -like '*PublicAPI.Unshipped.txt') { + $changedAPIBaselines.Add($file) + } } } diff --git a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt index 99c76cbcec82..07f76fca9e9b 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt @@ -24,3 +24,4 @@ Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void +~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection diff --git a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt index ebe087a2b9b1..ab058de62d44 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt @@ -1,2 +1 @@ #nullable enable -~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection From fa836498ef5434ec91ee33b4c76d0d5edfa3706b Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 16 Feb 2021 19:25:24 -0800 Subject: [PATCH 08/18] Update CodeCheck.ps1 --- eng/scripts/CodeCheck.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index b283427d99c4..d51605893138 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -207,7 +207,7 @@ try { $changedAPIBaselines.Add($file) } # Check for changes in Unshipped in servicing branches - if ($targetBranch -like 'release*' && $file -like '*PublicAPI.Unshipped.txt') { + if ($targetBranch -like 'release*' -and $file -like '*PublicAPI.Unshipped.txt') { $changedAPIBaselines.Add($file) } } From bf3f3b001ab450cc3d40243ef5fed56286929fa8 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 17 Feb 2021 10:42:39 -0800 Subject: [PATCH 09/18] Stylizing --- docs/APIBaselines.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index 7389c84d9bdb..e50cd1d3aacf 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -10,12 +10,12 @@ When creating a new implementation (i.e. src) project, it's necessary to manuall 1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Unshipped.txt` 1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project 1. `{directory containing relevant *.slnf}\startvs.cmd` -1. F6 # or whatever your favourite build gesture is +1. F6 *or whatever your favourite build gesture is* 1. Click on a RS0016 (or whatever) error 1. Right click in editor on underscored symbol or go straight to the “quick fix” icon to its left. Control-. also works. 1. Choose “Add Blah to public API” / “Fix all occurrences in … Solution” 1. Click Apply -1. F6 # again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon) +1. F6 *again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon)* 1. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed `[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]` or @@ -63,4 +63,4 @@ Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Dis ## Updating baselines after major releases -This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi. The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt \ No newline at end of file +This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi. The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt From eca6d06c132dd0f48e1dc147d4990adced79d94e Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 17 Feb 2021 20:57:03 -0800 Subject: [PATCH 10/18] Apply suggestions from code review Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com> --- .azure/pipelines/ci.yml | 3 --- docs/APIBaselines.md | 2 +- eng/scripts/CodeCheck.ps1 | 10 +++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.azure/pipelines/ci.yml b/.azure/pipelines/ci.yml index cdd968fb0ab4..f4cb66affec1 100644 --- a/.azure/pipelines/ci.yml +++ b/.azure/pipelines/ci.yml @@ -128,9 +128,6 @@ stages: steps: - powershell: ./eng/scripts/CodeCheck.ps1 -ci $(_InternalRuntimeDownloadArgs) displayName: Run eng/scripts/CodeCheck.ps1 - env: - PULLREQUEST_SOURCEBRANCH: $(System.PullRequest.SourceBranch) - PULLREQUEST_TARGETBRANCH: $(System.PullRequest.TargetBranch) artifacts: - name: Code_Check_Logs path: artifacts/log/ diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index e50cd1d3aacf..329799f2c4aa 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -63,4 +63,4 @@ Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Dis ## Updating baselines after major releases -This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi. The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt +This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi (or an Arcade successor). The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index d51605893138..254566499ba1 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -191,17 +191,17 @@ try { } } - $targetBranch = $env:PULLREQUEST_TARGETBRANCH - $sourceBranch = $env:PULLREQUEST_SOURCEBRANCH + $targetBranch = $env:SYSTEM_PULLREQUEST_TARGETBRANCH + $sourceBranch = $env:SYSTEM_PULLREQUEST_SOURCEBRANCH # Retrieve the set of changed files compared to main Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" - $changedFilesFromMain = git --no-pager diff origin/$targetBranch...origin/$sourceBranch --ignore-space-change --name-only --diff-filter=ar + $changedFilesFromTarget = git --no-pager diff origin/$targetBranch...origin/$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() - if ($changedFilesFromMain) { - foreach ($file in $changedFilesFromMain) { + if ($changedFilesFromTarget) { + foreach ($file in $changedFilesFromTarget) { # Check for changes in Shipped in all branches if ($file -like '*PublicAPI.Shipped.txt') { $changedAPIBaselines.Add($file) From 4a4801bccd9afd48baee1e7c1097d295ce98734b Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 22 Feb 2021 09:51:44 -0800 Subject: [PATCH 11/18] Update APIBaselines.md --- docs/APIBaselines.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index 329799f2c4aa..d6c108bbbdfc 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -1,6 +1,8 @@ # API Baselines -This document contains information regarding API baseline files and how to work with them. +This document contains information regarding API baseline files and how to work with them. For documentation on how these files works, consult: +- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md +- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md ## Add baseline files for new projects @@ -8,22 +10,9 @@ When creating a new implementation (i.e. src) project, it's necessary to manuall 1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Shipped.txt` 1. `cp .\eng\PublicAPI.empty.txt {new folder}\PublicAPI.Unshipped.txt` -1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project -1. `{directory containing relevant *.slnf}\startvs.cmd` -1. F6 *or whatever your favourite build gesture is* -1. Click on a RS0016 (or whatever) error -1. Right click in editor on underscored symbol or go straight to the “quick fix” icon to its left. Control-. also works. -1. Choose “Add Blah to public API” / “Fix all occurrences in … Solution” -1. Click Apply -1. F6 *again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon)* -1. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed - `[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]` - or - `[SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]` -More information available in -- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md -- https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md +See [Steps for adding and updating APIs](#steps-for-adding-and-updating-apis) for steps on how to add APIs to the Unshipped.txt files + ## PublicAPI.Shipped.txt @@ -31,7 +20,7 @@ This file contains APIs that were released in the last major version. This file ## PublicAPI.Unshipped.txt -This file contains new APIs since the last major version. +This file contains new APIs since the last major version. Steps for working with changes in APIs and updating this file are found in [Steps for adding and updating APIs](#steps-for-adding-and-updating-apis). ### New APIs @@ -61,6 +50,21 @@ Two new entry needs to be added to the PublicAPI.Unshipped.txt file for an updat Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Discriminator.get -> string? ``` +### Steps for adding and updating APIs + +1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project +1. `{directory containing relevant *.slnf}\startvs.cmd` +1. F6 *or whatever your favourite build gesture is* +1. Click on a RS0016 (or whatever) error +1. Right click in editor on underscored symbol or go straight to the “quick fix” icon to its left. Control-. also works. +1. Choose “Add Blah to public API” / “Fix all occurrences in … Solution” +1. Click Apply +1. F6 *again to see if the fixer missed anything or if other RS00xx errors show up (not uncommon)* +1. Suppress or fix other problems as needed but please suppress (if suppressing) using attributes and not globally or with `#pragma`s because attributes make the justification obvious e.g. for common errors that can't be fixed + `[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]` + or + `[SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]` + ## Updating baselines after major releases This will be performed by the build team using scripts at https://github.com/dotnet/roslyn/tree/master/scripts/PublicApi (or an Arcade successor). The process moves the content of PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt From 180a59717f16d19ba99cbcd031f281cca620ec29 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 22 Feb 2021 09:56:27 -0800 Subject: [PATCH 12/18] Update APIBaselines.md --- docs/APIBaselines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index d6c108bbbdfc..824917de32af 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -1,6 +1,6 @@ # API Baselines -This document contains information regarding API baseline files and how to work with them. For documentation on how these files works, consult: +This document contains information regarding API baseline files and how to work with them. For additional details on how these files works, consult: - https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md - https://github.com/dotnet/roslyn-analyzers/blob/master/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md From d06b5205111cfc854b46076b257285d698b12d01 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 22 Feb 2021 11:23:31 -0800 Subject: [PATCH 13/18] Update script for internal --- eng/scripts/CodeCheck.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 254566499ba1..e2ffcd47d46c 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -192,12 +192,18 @@ try { } $targetBranch = $env:SYSTEM_PULLREQUEST_TARGETBRANCH + if (-not ($targetBranch.StartsWith('refs/heads/'))) { + $targetBranch = refs/heads$targetBranch + } $sourceBranch = $env:SYSTEM_PULLREQUEST_SOURCEBRANCH + if (-not ($sourceBranch.StartsWith('refs/heads/'))) { + $sourceBranch = refs/heads$sourceBranch + } # Retrieve the set of changed files compared to main Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" - $changedFilesFromTarget = git --no-pager diff origin/$targetBranch...origin/$sourceBranch --ignore-space-change --name-only --diff-filter=ar + $changedFilesFromTarget = git --no-pager diff $targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() if ($changedFilesFromTarget) { From 3b4bb5897f8b03f76e5234b7a4f514cd01d66760 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 22 Feb 2021 14:15:07 -0800 Subject: [PATCH 14/18] Debug internal --- eng/scripts/CodeCheck.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index e2ffcd47d46c..8c87372dacf0 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -202,6 +202,8 @@ try { # Retrieve the set of changed files compared to main Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" + git remote -v + git branch $changedFilesFromTarget = git --no-pager diff $targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() From f1f6ebb7df1b1212ce4aa0fcf17ad109af6f33ba Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 22 Feb 2021 16:46:48 -0800 Subject: [PATCH 15/18] Simplify for internal --- eng/scripts/CodeCheck.ps1 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 8c87372dacf0..733af901d0cd 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -193,19 +193,15 @@ try { $targetBranch = $env:SYSTEM_PULLREQUEST_TARGETBRANCH if (-not ($targetBranch.StartsWith('refs/heads/'))) { - $targetBranch = refs/heads$targetBranch - } - $sourceBranch = $env:SYSTEM_PULLREQUEST_SOURCEBRANCH - if (-not ($sourceBranch.StartsWith('refs/heads/'))) { - $sourceBranch = refs/heads$sourceBranch + $targetBranch = $targetBranch.Replace('refs/heads/','') } # Retrieve the set of changed files compared to main - Write-Host "Checking for changes to API baseline files $targetBranch...$sourceBranch" + Write-Host "Checking for changes to API baseline files $targetBranch" git remote -v git branch - $changedFilesFromTarget = git --no-pager diff $targetBranch...$sourceBranch --ignore-space-change --name-only --diff-filter=ar + $changedFilesFromTarget = git --no-pager diff origin/$targetBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() if ($changedFilesFromTarget) { From 09a640fe3a75fddc5f18d7ffc6dd0563c205fc55 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 22 Feb 2021 17:11:51 -0800 Subject: [PATCH 16/18] Debug internal --- eng/scripts/CodeCheck.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 733af901d0cd..595c81809589 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -192,7 +192,7 @@ try { } $targetBranch = $env:SYSTEM_PULLREQUEST_TARGETBRANCH - if (-not ($targetBranch.StartsWith('refs/heads/'))) { + if ($targetBranch.StartsWith('refs/heads/')) { $targetBranch = $targetBranch.Replace('refs/heads/','') } From ae3932976dd20ec08301324dc5e407c2c187ba85 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 23 Feb 2021 10:42:07 -0800 Subject: [PATCH 17/18] Test internal --- eng/scripts/CodeCheck.ps1 | 2 -- src/Caching/SqlServer/src/PublicAPI.Shipped.txt | 1 - src/Caching/SqlServer/src/PublicAPI.Unshipped.txt | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/eng/scripts/CodeCheck.ps1 b/eng/scripts/CodeCheck.ps1 index 595c81809589..3c196f775782 100644 --- a/eng/scripts/CodeCheck.ps1 +++ b/eng/scripts/CodeCheck.ps1 @@ -198,8 +198,6 @@ try { # Retrieve the set of changed files compared to main Write-Host "Checking for changes to API baseline files $targetBranch" - git remote -v - git branch $changedFilesFromTarget = git --no-pager diff origin/$targetBranch --ignore-space-change --name-only --diff-filter=ar $changedAPIBaselines = [System.Collections.Generic.List[string]]::new() diff --git a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt index 07f76fca9e9b..99c76cbcec82 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt @@ -24,4 +24,3 @@ Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void -~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection diff --git a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt index ab058de62d44..ebe087a2b9b1 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection From d2e1f92824f8f7c3a0510e00e31eeeafbe523bbb Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 24 Feb 2021 16:18:45 -0800 Subject: [PATCH 18/18] Remove test code --- docs/APIBaselines.md | 3 +-- src/Caching/SqlServer/src/PublicAPI.Shipped.txt | 1 + src/Caching/SqlServer/src/PublicAPI.Unshipped.txt | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/APIBaselines.md b/docs/APIBaselines.md index 824917de32af..75a94caef6cd 100644 --- a/docs/APIBaselines.md +++ b/docs/APIBaselines.md @@ -13,7 +13,6 @@ When creating a new implementation (i.e. src) project, it's necessary to manuall See [Steps for adding and updating APIs](#steps-for-adding-and-updating-apis) for steps on how to add APIs to the Unshipped.txt files - ## PublicAPI.Shipped.txt This file contains APIs that were released in the last major version. This file should only be modified after a major release by the build team and should never be modified otherwise. @@ -52,7 +51,7 @@ Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator.Dis ### Steps for adding and updating APIs -1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project +1. Update AspNetCore.sln and relevant `*.slnf` file to include the new project if needed 1. `{directory containing relevant *.slnf}\startvs.cmd` 1. F6 *or whatever your favourite build gesture is* 1. Click on a RS0016 (or whatever) error diff --git a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt index 99c76cbcec82..07f76fca9e9b 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Shipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Shipped.txt @@ -24,3 +24,4 @@ Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.SystemClock.set -> void ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.get -> string ~Microsoft.Extensions.Caching.SqlServer.SqlServerCacheOptions.TableName.set -> void +~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection diff --git a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt index ebe087a2b9b1..ab058de62d44 100644 --- a/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt +++ b/src/Caching/SqlServer/src/PublicAPI.Unshipped.txt @@ -1,2 +1 @@ #nullable enable -~static Microsoft.Extensions.DependencyInjection.SqlServerCachingServicesExtensions.AddDistributedSqlServerCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> Microsoft.Extensions.DependencyInjection.IServiceCollection