Skip to content

Commit cf355d1

Browse files
authored
Enable PublicApiAnalyzers (#3055)
* Enable PublicApiAnalyzers * Add internal api tracking * remove api files in tests update global suppressions and null annotations disable warnings where not appropriate fix markshipped script
1 parent 08251ae commit cf355d1

File tree

284 files changed

+6699
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

284 files changed

+6699
-14
lines changed

.editorconfig

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
5454
# name all constant fields using PascalCase
5555
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
5656
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
57-
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
57+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
5858

5959
dotnet_naming_symbols.constant_fields.applicable_kinds = field
6060
dotnet_naming_symbols.constant_fields.required_modifiers = const
@@ -64,7 +64,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
6464
# static fields should have s_ prefix
6565
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
6666
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
67-
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
67+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
6868

6969
dotnet_naming_symbols.static_fields.applicable_kinds = field
7070
dotnet_naming_symbols.static_fields.required_modifiers = static
@@ -75,7 +75,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case
7575
# internal and private fields should be _camelCase
7676
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
7777
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
78-
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
78+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
7979

8080
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
8181
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
@@ -141,6 +141,16 @@ csharp_space_between_square_brackets = false
141141
# RS0030: Do not used banned APIs
142142
dotnet_diagnostic.RS0030.severity = error
143143

144+
# https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md
145+
dotnet_diagnostic.RS0051.severity = error
146+
dotnet_diagnostic.RS0052.severity = error
147+
dotnet_diagnostic.RS0053.severity = error
148+
dotnet_diagnostic.RS0054.severity = error
149+
dotnet_diagnostic.RS0055.severity = error
150+
dotnet_diagnostic.RS0057.severity = error
151+
dotnet_diagnostic.RS0058.severity = error
152+
dotnet_diagnostic.RS0061.severity = error
153+
144154
# CA1000: Do not declare static members on generic types
145155
dotnet_diagnostic.CA1000.severity = error
146156

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
<!--CVE-2023-29331-->
9696
<SystemFormatsAsn1Version>8.0.1</SystemFormatsAsn1Version>
9797
<BannedApiAnalyzersVersion>3.3.4</BannedApiAnalyzersVersion>
98+
<PublicApiAnalyzersVersion>3.3.4</PublicApiAnalyzersVersion>
9899
</PropertyGroup>
99100

100101
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0'">
@@ -195,5 +196,9 @@
195196
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
196197
</PackageReference>
197198
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\BannedSymbols.txt" />
199+
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="$(PublicApiAnalyzersVersion)">
200+
<PrivateAssets>all</PrivateAssets>
201+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
202+
</PackageReference>
198203
</ItemGroup>
199204
</Project>

benchmark/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# NOTE: Requires **VS2019 16.3** or later
2+
3+
# Rules for files in tests directory
4+
5+
# Code files
6+
[*.{cs,txt}]
7+
8+
# RS0016: Add public types and members to the declared API
9+
dotnet_diagnostic.RS0016.severity = none
10+
11+
RS0037: Enable tracking of nullability of reference types in the declared API
12+
dotnet_diagnostic.RS0037.severity = none
13+
14+
# RS0031: The list of banned symbols contains a duplicate
15+
dotnet_diagnostic.RS0031.severity = none
16+
17+
# RS0051: Add internal types and members to the declared API
18+
dotnet_diagnostic.RS0051.severity = none

benchmark/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@
2020
<ItemGroup>
2121
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\BannedSymbols.txt" />
2222
</ItemGroup>
23+
24+
<PropertyGroup>
25+
<!--RS0016: Add public types and members to the declared API-->
26+
<NoWarn>RS0016</NoWarn>
27+
<!--RS0031: The list of banned symbols contains a duplicate-->
28+
<NoWarn>RS0031</NoWarn>
29+
</PropertyGroup>
2330
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#nullable enable
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Microsoft.Identity.Web.TokenAcquirerAppTokenCredential
2+
Microsoft.Identity.Web.TokenAcquirerAppTokenCredential.TokenAcquirerAppTokenCredential(Microsoft.Identity.Abstractions.ITokenAcquirer! tokenAcquirer) -> void
3+
Microsoft.Identity.Web.TokenAcquirerTokenCredential
4+
Microsoft.Identity.Web.TokenAcquirerTokenCredential.TokenAcquirerTokenCredential(Microsoft.Identity.Abstractions.ITokenAcquirer! tokenAcquirer) -> void
5+
override Microsoft.Identity.Web.TokenAcquirerAppTokenCredential.GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) -> Azure.Core.AccessToken
6+
override Microsoft.Identity.Web.TokenAcquirerAppTokenCredential.GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<Azure.Core.AccessToken>
7+
override Microsoft.Identity.Web.TokenAcquirerTokenCredential.GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) -> Azure.Core.AccessToken
8+
override Microsoft.Identity.Web.TokenAcquirerTokenCredential.GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<Azure.Core.AccessToken>

src/Microsoft.Identity.Web.Azure/TokenAcquirerTokenCredential.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public TokenAcquirerTokenCredential(ITokenAcquirer tokenAcquirer)
2727
/// <inheritdoc/>
2828
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
2929
{
30-
AcquireTokenResult result = _tokenAcquirer.GetTokenForUserAsync(requestContext.Scopes, cancellationToken:cancellationToken)
30+
AcquireTokenResult result = _tokenAcquirer.GetTokenForUserAsync(requestContext.Scopes, cancellationToken: cancellationToken)
3131
.GetAwaiter()
3232
.GetResult();
3333
return new AccessToken(result.AccessToken!, result.ExpiresOn);
@@ -36,7 +36,7 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
3636
/// <inheritdoc/>
3737
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
3838
{
39-
AcquireTokenResult result = await _tokenAcquirer.GetTokenForUserAsync(requestContext.Scopes, cancellationToken:cancellationToken).ConfigureAwait(false);
39+
AcquireTokenResult result = await _tokenAcquirer.GetTokenForUserAsync(requestContext.Scopes, cancellationToken: cancellationToken).ConfigureAwait(false);
4040
return new AccessToken(result.AccessToken!, result.ExpiresOn);
4141
}
4242
}

src/Microsoft.Identity.Web.Certificate/CertificateErrorMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.Identity.Web
99
internal static class CertificateErrorMessage
1010
{
1111
// Configuration IDW10100 = "IDW10100:"
12-
public const string ClientSecretAndCertficateNull =
12+
public const string ClientSecretAndCertificateNull =
1313
"IDW10104: Both client secret and client certificate cannot be null or whitespace, " +
1414
"and only ONE must be included in the configuration of the web app when calling a web API. " +
1515
"For instance, in the appsettings.json file. ";
@@ -28,6 +28,6 @@ internal static class CertificateErrorMessage
2828
"StoreName must be empty or one of '{0}'. ";
2929

3030
// Obsolete messages IDW10800 = "IDW10800:"
31-
public const string FromStoreWithThumprintIsObsolete = "IDW10803: Use FromStoreWithThumbprint instead, due to spelling error. ";
31+
public const string FromStoreWithThumbprintIsObsolete = "IDW10803: Use FromStoreWithThumbprint instead, due to spelling error. ";
3232
}
3333
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#nullable enable
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#nullable enable
2+
const Microsoft.Identity.Web.CertificateConstants.MediaTypePksc12 = "application/x-pkcs12" -> string!
3+
const Microsoft.Identity.Web.CertificateConstants.PersonalUserCertificateStorePath = "CurrentUser/My" -> string!
4+
const Microsoft.Identity.Web.CertificateErrorMessage.BothClientSecretAndCertificateProvided = "IDW10105: Both client secret and client certificate, cannot be included in the configuration of the web app when calling a web API. " -> string!
5+
const Microsoft.Identity.Web.CertificateErrorMessage.ClientCertificatesHaveExpiredOrCannotBeLoaded = "IDW10109: All client certificates passed to the configuration have expired or can't be loaded. " -> string!
6+
const Microsoft.Identity.Web.CertificateErrorMessage.ClientSecretAndCertificateNull = "IDW10104: Both client secret and client certificate cannot be null or whitespace, and only ONE must be included in the configuration of the web app when calling a web API. For instance, in the appsettings.json file. " -> string!
7+
const Microsoft.Identity.Web.CertificateErrorMessage.FromStoreWithThumbprintIsObsolete = "IDW10803: Use FromStoreWithThumbprint instead, due to spelling error. " -> string!
8+
const Microsoft.Identity.Web.CertificateErrorMessage.IncorrectNumberOfUriSegments = "IDW10702: Number of URI segments is incorrect: {0}, URI: {1}. " -> string!
9+
const Microsoft.Identity.Web.CertificateErrorMessage.InvalidBase64UrlString = "IDW10601: Invalid Base64URL string. " -> string!
10+
const Microsoft.Identity.Web.CertificateErrorMessage.InvalidCertificateStorePath = "IDW10703: Certificate store path must be of the form 'StoreLocation/StoreName'. StoreLocation must be one of 'CurrentUser', 'LocalMachine'. StoreName must be empty or one of '{0}'. " -> string!
11+
const Microsoft.Identity.Web.CertificateErrorMessage.OnlyPkcs12IsSupported = "IDW10701: Only PKCS #12 content type is supported. Found Content-Type: {0}. " -> string!
12+
Microsoft.Identity.Web.Base64EncodedCertificateLoader
13+
Microsoft.Identity.Web.Base64EncodedCertificateLoader.Base64EncodedCertificateLoader() -> void
14+
Microsoft.Identity.Web.Base64EncodedCertificateLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
15+
Microsoft.Identity.Web.Base64EncodedCertificateLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? credentialSourceLoaderParameters) -> System.Threading.Tasks.Task!
16+
Microsoft.Identity.Web.CertificateConstants
17+
Microsoft.Identity.Web.CertificateDescription.Container.get -> string?
18+
Microsoft.Identity.Web.CertificateDescription.Container.set -> void
19+
Microsoft.Identity.Web.CertificateDescription.ReferenceOrValue.get -> string?
20+
Microsoft.Identity.Web.CertificateDescription.ReferenceOrValue.set -> void
21+
Microsoft.Identity.Web.CertificateErrorMessage
22+
Microsoft.Identity.Web.CertificateLoaderHelper
23+
Microsoft.Identity.Web.CertificateLoaderHelper.CertificateLoaderHelper() -> void
24+
Microsoft.Identity.Web.FromPathCertificateLoader
25+
Microsoft.Identity.Web.FromPathCertificateLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
26+
Microsoft.Identity.Web.FromPathCertificateLoader.FromPathCertificateLoader() -> void
27+
Microsoft.Identity.Web.FromPathCertificateLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? _) -> System.Threading.Tasks.Task!
28+
Microsoft.Identity.Web.KeyVaultCertificateLoader
29+
Microsoft.Identity.Web.KeyVaultCertificateLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
30+
Microsoft.Identity.Web.KeyVaultCertificateLoader.KeyVaultCertificateLoader() -> void
31+
Microsoft.Identity.Web.KeyVaultCertificateLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? _) -> System.Threading.Tasks.Task!
32+
Microsoft.Identity.Web.SignedAssertionFilePathCredentialsLoader
33+
Microsoft.Identity.Web.SignedAssertionFilePathCredentialsLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
34+
Microsoft.Identity.Web.SignedAssertionFilePathCredentialsLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? credentialSourceLoaderParameters) -> System.Threading.Tasks.Task!
35+
Microsoft.Identity.Web.SignedAssertionFilePathCredentialsLoader.SignedAssertionFilePathCredentialsLoader(Microsoft.Extensions.Logging.ILogger? logger) -> void
36+
Microsoft.Identity.Web.SignedAssertionFromManagedIdentityCredentialLoader
37+
Microsoft.Identity.Web.SignedAssertionFromManagedIdentityCredentialLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
38+
Microsoft.Identity.Web.SignedAssertionFromManagedIdentityCredentialLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? credentialSourceLoaderParameters) -> System.Threading.Tasks.Task!
39+
Microsoft.Identity.Web.SignedAssertionFromManagedIdentityCredentialLoader.SignedAssertionFromManagedIdentityCredentialLoader(Microsoft.Extensions.Logging.ILogger<Microsoft.Identity.Web.DefaultCredentialsLoader!>! logger) -> void
40+
Microsoft.Identity.Web.StoreWithDistinguishedNameCertificateLoader
41+
Microsoft.Identity.Web.StoreWithDistinguishedNameCertificateLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
42+
Microsoft.Identity.Web.StoreWithDistinguishedNameCertificateLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? _) -> System.Threading.Tasks.Task!
43+
Microsoft.Identity.Web.StoreWithDistinguishedNameCertificateLoader.StoreWithDistinguishedNameCertificateLoader() -> void
44+
Microsoft.Identity.Web.StoreWithThumbprintCertificateLoader
45+
Microsoft.Identity.Web.StoreWithThumbprintCertificateLoader.CredentialSource.get -> Microsoft.Identity.Abstractions.CredentialSource
46+
Microsoft.Identity.Web.StoreWithThumbprintCertificateLoader.LoadIfNeededAsync(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription, Microsoft.Identity.Abstractions.CredentialSourceLoaderParameters? _) -> System.Threading.Tasks.Task!
47+
Microsoft.Identity.Web.StoreWithThumbprintCertificateLoader.StoreWithThumbprintCertificateLoader() -> void
48+
static Microsoft.Identity.Web.Base64EncodedCertificateLoader.LoadFromBase64Encoded(string! certificateBase64, string! password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags x509KeyStorageFlags) -> System.Security.Cryptography.X509Certificates.X509Certificate2!
49+
static Microsoft.Identity.Web.Base64EncodedCertificateLoader.LoadFromBase64Encoded(string! certificateBase64, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags x509KeyStorageFlags) -> System.Security.Cryptography.X509Certificates.X509Certificate2!
50+
static Microsoft.Identity.Web.CertificateLoaderHelper.DetermineX509KeyStorageFlag() -> System.Security.Cryptography.X509Certificates.X509KeyStorageFlags
51+
static Microsoft.Identity.Web.CertificateLoaderHelper.DetermineX509KeyStorageFlag(Microsoft.Identity.Abstractions.CredentialDescription! credentialDescription) -> System.Security.Cryptography.X509Certificates.X509KeyStorageFlags
52+
static Microsoft.Identity.Web.CertificateLoaderHelper.FindCertificateByCriterium(System.Security.Cryptography.X509Certificates.X509Store! x509Store, System.Security.Cryptography.X509Certificates.X509FindType identifierCriterium, string! certificateIdentifier) -> System.Security.Cryptography.X509Certificates.X509Certificate2?
53+
static Microsoft.Identity.Web.CertificateLoaderHelper.ParseStoreLocationAndName(string! storeDescription, ref System.Security.Cryptography.X509Certificates.StoreLocation certificateStoreLocation, ref System.Security.Cryptography.X509Certificates.StoreName certificateStoreName) -> void
54+
static Microsoft.Identity.Web.KeyVaultCertificateLoader.LoadFromKeyVault(string! keyVaultUrl, string! certificateName, string? managedIdentityClientId, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags x509KeyStorageFlags) -> System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2?>!
55+
static Microsoft.Identity.Web.KeyVaultCertificateLoader.UserAssignedManagedIdentityClientId.get -> string?
56+
static Microsoft.Identity.Web.KeyVaultCertificateLoader.UserAssignedManagedIdentityClientId.set -> void

0 commit comments

Comments
 (0)