Skip to content

Commit 80e290c

Browse files
committed
cleanup references and test code, and FxCop Analyzers
1 parent 83f9feb commit 80e290c

File tree

10 files changed

+280
-224
lines changed

10 files changed

+280
-224
lines changed

CommonRuleSet.ruleset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@
8484
<Rule Id="SA1649" Action="None" />
8585
<Rule Id="SA1652" Action="None" />
8686
</Rules>
87+
<Rules AnalyzerId="Microsoft.NetCore.Analyzers" RuleNamespace="Microsoft.NetCore.Analyzers">
88+
<Rule Id="CA1303" Action="None" />
89+
</Rules>
8790
</RuleSet>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ When you install the package, it should be added to your `.csproj`. Alternativel
2323

2424
```xml
2525
<ItemGroup>
26-
<PackageReference Include="ZNetCS.AspNetCore.Authentication.Basic" Version="3.0.1" />
26+
<PackageReference Include="ZNetCS.AspNetCore.Authentication.Basic" Version="3.0.2" />
2727
</ItemGroup>
2828
```
2929

src/ZNetCS.AspNetCore.Authentication.Basic/BasicAuthenticationExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ public static AuthenticationBuilder AddBasicAuthentication(
7676
this AuthenticationBuilder builder,
7777
string authenticationScheme,
7878
Action<BasicAuthenticationOptions> configureOptions)
79-
=> builder.AddScheme<BasicAuthenticationOptions, BasicAuthenticationHandler>(authenticationScheme, configureOptions);
79+
{
80+
if (builder == null)
81+
{
82+
throw new ArgumentNullException(nameof(builder));
83+
}
84+
85+
return builder.AddScheme<BasicAuthenticationOptions, BasicAuthenticationHandler>(authenticationScheme, configureOptions);
86+
}
8087

8188
#endregion
8289
}

src/ZNetCS.AspNetCore.Authentication.Basic/BasicAuthenticationHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public BasicAuthenticationHandler(IOptionsMonitor<BasicAuthenticationOptions> op
100100
protected override Task<object> CreateEventsAsync() => Task.FromResult<object>(new BasicAuthenticationEvents());
101101

102102
/// <inheritdoc/>
103+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Just for validation, the quickest")]
104+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:Specify StringComparison", Justification = "Invalid overload; known bug in code analysis")]
103105
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
104106
{
105107
// RFC 7230 section 3.2.2
@@ -112,7 +114,7 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
112114
return AuthenticateResult.NoResult();
113115
}
114116

115-
string basicAuthorizationHeader = authorizationHeaderValues.FirstOrDefault(s => s.StartsWith(Basic + ' ', StringComparison.OrdinalIgnoreCase));
117+
string basicAuthorizationHeader = authorizationHeaderValues.FirstOrDefault(s => s.StartsWith(Basic + ' ', StringComparison.InvariantCultureIgnoreCase));
116118

117119
// Authorization header is not 'Basic' so there is nothing to do by this middleware
118120
if (string.IsNullOrEmpty(basicAuthorizationHeader))

src/ZNetCS.AspNetCore.Authentication.Basic/ZNetCS.AspNetCore.Authentication.Basic.csproj

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,54 @@
44
<Description>A simple basic authentication middleware.</Description>
55
<Copyright>Marcin Smółka zNET Computer Solutions</Copyright>
66
<Authors>Marcin Smółka</Authors>
7-
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
7+
<TargetFrameworks>net461;netstandard2.0;netcoreapp3.0</TargetFrameworks>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
<AssemblyName>ZNetCS.AspNetCore.Authentication.Basic</AssemblyName>
1010
<PackageId>ZNetCS.AspNetCore.Authentication.Basic</PackageId>
1111
<PackageTags>aspnetcore;aspnetcoremvc;middleware;authentication;basic;ASP.NET;MVC</PackageTags>
1212
<PackageProjectUrl>https://github.com/msmolka/ZNetCS.AspNetCore.Authentication.Basic</PackageProjectUrl>
1313
<PackageLicenseUrl>https://raw.githubusercontent.com/msmolka/ZNetCS.AspNetCore.Authentication.Basic/master/LICENSE</PackageLicenseUrl>
14+
<PackageReleaseNotes>Cleanup dependencies.</PackageReleaseNotes>
1415
<RepositoryType>git</RepositoryType>
1516
<RepositoryUrl>https://github.com/msmolka/ZNetCS.AspNetCore.Authentication.Basic</RepositoryUrl>
16-
<VersionPrefix>3.0.1</VersionPrefix>
17-
<NoWarn>$(NoWarn);NU5125</NoWarn> <!-- remove once tools are truly ready for NuGet's new 'license' element -->
17+
<VersionPrefix>3.0.2</VersionPrefix>
18+
<NoWarn>$(NoWarn);NU5125</NoWarn>
19+
<!-- remove once tools are truly ready for NuGet's new 'license' element -->
1820
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
1921
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
2022
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
2123
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
2224
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
25+
<CodeAnalysisRuleSet>..\..\CommonRuleSet.ruleset</CodeAnalysisRuleSet>
26+
<LangVersion>8.0</LangVersion>
2327
</PropertyGroup>
24-
28+
2529
<ItemGroup>
2630
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
2731
</ItemGroup>
2832

29-
<PropertyGroup>
30-
<CodeAnalysisRuleSet>..\..\CommonRuleSet.ruleset</CodeAnalysisRuleSet>
31-
</PropertyGroup>
32-
33-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net461|AnyCPU'">
34-
</PropertyGroup>
35-
36-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net461|AnyCPU'">
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
3734
<TreatWarningsAsErrors />
3835
</PropertyGroup>
3936

4037
<ItemGroup>
41-
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
42-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
43-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
44-
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
45-
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
46-
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" />
47-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-rc.114">
48-
<PrivateAssets>All</PrivateAssets>
38+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="all" />
39+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6">
40+
<PrivateAssets>all</PrivateAssets>
41+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
42+
</PackageReference>
43+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
44+
<PrivateAssets>all</PrivateAssets>
45+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4946
</PackageReference>
5047
</ItemGroup>
5148

52-
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
53-
<Reference Include="System" />
54-
<Reference Include="Microsoft.CSharp" />
49+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
50+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
51+
</ItemGroup>
52+
53+
<ItemGroup Condition="'$(TargetFramework)' == 'net461' OR '$(TargetFramework)' == 'netstandard2.0'">
54+
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
5555
</ItemGroup>
5656

5757
</Project>

0 commit comments

Comments
 (0)