Skip to content

Commit ce1e7b2

Browse files
More code analysis clean up
1 parent 5cbb890 commit ce1e7b2

File tree

40 files changed

+94
-33
lines changed

40 files changed

+94
-33
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ csharp_space_between_method_declaration_parameter_list_parentheses = true
9090
csharp_space_between_method_call_parameter_list_parentheses = true
9191
csharp_space_between_parentheses = control_flow_statements, expressions
9292

93+
# primary construcrtors
94+
csharp_style_prefer_primary_constructors = false:none
95+
9396
# style code suppressions
9497
dotnet_diagnostic.SA1002.severity = none
9598
dotnet_diagnostic.SA1003.severity = none

src/Abstractions/src/Asp.Versioning.Abstractions/netstandard2.0/FormatWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal FormatWriter(
4545

4646
public bool Succeeded { get; private set; }
4747

48-
public int Written => totalWritten;
48+
public readonly int Written => totalWritten;
4949

5050
public void Write( in FormatToken token )
5151
{

src/Abstractions/test/Asp.Versioning.Abstractions.Tests/ApiVersionTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: DX
4+
35
namespace Asp.Versioning;
46

57
public partial class ApiVersionTest

src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/given a versioned ApiController per namespace/when using a url segment and attribute-based routing.cs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#pragma warning disable IDE1006 // Naming Styles
44

5+
//// Ignore Spelling: Dbased
6+
57
namespace given_a_versioned_ApiController_per_namespace;
68

79
using Asp.Versioning;

src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/given a versioned ApiController per namespace/when using a url segment and convention-based routing.cs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#pragma warning disable IDE1006 // Naming Styles
44

5+
//// Ignore Spelling: Dbased
6+
57
namespace given_a_versioned_ApiController_per_namespace;
68

79
using Asp.Versioning;

src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/ODataAcceptanceTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dspecific
4+
35
namespace Asp.Versioning.OData;
46

57
using static System.Net.HttpStatusCode;

src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Conventions/ODataValidationSettingsConventionTest.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dlike
4+
//// Ignore Spelling: Multipart
5+
//// Ignore Spelling: nonaction
6+
//// Ignore Spelling: nonquery
7+
38
namespace Asp.Versioning.Conventions;
49

510
using Asp.Versioning.Description;

src/AspNet/OData/test/Asp.Versioning.WebApi.OData.Tests/Routing/VersionedAttributeRoutingConventionTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dneutral
4+
35
namespace Asp.Versioning.Routing;
46

57
using Microsoft.AspNet.OData;

src/AspNet/WebApi/src/Asp.Versioning.WebApi/Controllers/ActionSelectorCacheItem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Asp.Versioning.Controllers;
2323
/// </summary>
2424
internal sealed class ActionSelectorCacheItem
2525
{
26-
private static readonly HttpMethod[] cacheListMethodKinds = new[] { HttpMethod.Get, HttpMethod.Put, HttpMethod.Post };
26+
private static readonly HttpMethod[] cacheListMethodKinds = [HttpMethod.Get, HttpMethod.Put, HttpMethod.Post];
2727
private readonly HttpControllerDescriptor controllerDescriptor;
2828
private readonly CandidateAction[] combinedCandidateActions;
2929
private readonly Dictionary<HttpActionDescriptor, string[]> actionParameterNames = [];

src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/ApiExplorer/VersionedApiExplorerTest.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dcase
4+
//// Ignore Spelling: Dinsensitive
35

46
namespace Asp.Versioning.ApiExplorer;
7+
58
using Asp.Versioning.Models;
69
using Asp.Versioning.Routing;
710
using Asp.Versioning.Simulators;

src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Description/ApiDescriptionGroupCollectionTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: denormalized
4+
35
namespace Asp.Versioning.Description;
46

57
using System.Collections.ObjectModel;

src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Models/GenericMutableObject{T}.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Foo
4+
35
namespace Asp.Versioning.Models;
46

57
public class GenericMutableObject<T> : List<T>

src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Models/MutableObject.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Foo
4+
35
namespace Asp.Versioning.Models;
46

57
public class MutableObject

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Controllers/HttpControllerDescriptorGroupTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: eq
4+
35
namespace Asp.Versioning.Controllers;
46

57
using System.Collections.ObjectModel;

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Dispatcher/ApiVersionControllerSelectorTest.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dbased
4+
//// Ignore Spelling: Dneutral
5+
36
namespace Asp.Versioning.Dispatcher;
47

58
using Asp.Versioning;

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/MediaTypeApiVersionReaderBuilderTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void read_should_retrieve_version_from_content_type_and_accept()
125125
var versions = reader.Read( request );
126126

127127
// assert
128-
versions.Should().BeEquivalentTo( new[] { "1.5", "2.0" } );
128+
versions.Should().BeEquivalentTo( ["1.5", "2.0"] );
129129
}
130130

131131
[Fact]
@@ -246,7 +246,7 @@ public void read_should_only_retrieve_included_media_types()
246246
[InlineData( "application/vnd-v{v}+json", "v", "application/vnd-v2.1+json", "2.1" )]
247247
[InlineData( "application/vnd-v{ver}+json", "ver", "application/vnd-v2022-11-01+json", "2022-11-01" )]
248248
[InlineData( "application/vnd-{version}+xml", "version", "application/vnd-1.1-beta+xml", "1.1-beta" )]
249-
public void read_should_retreive_version_from_media_type_template(
249+
public void read_should_retrieve_version_from_media_type_template(
250250
string template,
251251
string parameterName,
252252
string mediaType,

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/MediaTypeApiVersionReaderTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void read_should_retrieve_version_from_content_type_and_accept()
111111
var versions = reader.Read( request );
112112

113113
// assert
114-
versions.Should().BeEquivalentTo( new[] { "1.5", "2.0" } );
114+
versions.Should().BeEquivalentTo( ["1.5", "2.0"] );
115115
}
116116

117117
[Fact]

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/QueryStringApiVersionReaderTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public void read_should_not_throw_exception_when_duplicate_api_versions_are_requ
8686
}
8787

8888
[Theory]
89-
[InlineData( new object[] { new string[0] } )]
90-
[InlineData( new object[] { new[] { "api-version" } } )]
89+
[InlineData( [new string[0]] )]
90+
[InlineData( [new[] { "api-version" }] )]
9191
public void add_parameters_should_add_single_parameter_from_query_string( string[] parameterNames )
9292
{
9393
// arrange

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/ReportApiVersionsAttributeTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dneutral
4+
35
namespace Asp.Versioning;
46

57
using Asp.Versioning.Simulators;

src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/AdminController.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Admin
4+
35
namespace Asp.Versioning.Simulators;
46

57
using System.Web.Http;

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/ODataAcceptanceTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dspecific
4+
35
namespace Asp.Versioning.OData;
46

57
using static System.Net.HttpStatusCode;

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Conventions/ODataValidationSettingsConventionTest.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dlike
4+
//// Ignore Spelling: Multipart
5+
//// Ignore Spelling: nonaction
6+
//// Ignore Spelling: nonquery
7+
38
namespace Asp.Versioning.Conventions;
49

510
using Asp.Versioning.OData;

src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Routing/VersionedAttributeRoutingConventionTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dneutral
4+
35
namespace Asp.Versioning.Routing;
46

57
using Asp.Versioning.OData;

src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests/MediaTypeApiVersionReaderTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public void read_should_retrieve_version_from_content_type()
3333
var request = new Mock<HttpRequest>();
3434
var headers = new Mock<IHeaderDictionary>();
3535

36+
#pragma warning disable ASP0015 // Suggest using IHeaderDictionary properties
3637
headers.SetupGet( h => h["Content-Type"] ).Returns( new StringValues( "application/json;v=2.0" ) );
38+
#pragma warning restore ASP0015 // Suggest using IHeaderDictionary properties
3739
request.SetupGet( r => r.Headers ).Returns( headers.Object );
3840
request.SetupProperty( r => r.Body, Null );
3941
request.SetupProperty( r => r.ContentLength, 0L );

src/AspNetCore/WebApi/test/Asp.Versioning.Mvc.ApiExplorer.Tests/ApiDescriptionExtensionsTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dneutral
4+
35
namespace Asp.Versioning.ApiExplorer;
46

57
using Microsoft.AspNetCore.Mvc.ApiExplorer;

src/AspNetCore/WebApi/test/Asp.Versioning.Mvc.Tests/ApiVersioningApplicationModelProviderTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dneutral
4+
35
namespace Asp.Versioning;
46

57
using Asp.Versioning.ApplicationModels;

src/AspNetCore/WebApi/test/Asp.Versioning.Mvc.Tests/ReportApiVersionsAttributeTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dneutral
4+
35
namespace Asp.Versioning;
46

57
using Microsoft.AspNetCore.Http;

src/Common/src/Common/ApiVersionReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static IApiVersionReader Combine(
4242

4343
if ( otherApiVersionReaders is null || ( count = otherApiVersionReaders.Length ) == 0 )
4444
{
45-
apiVersionReaders = new[] { apiVersionReader };
45+
apiVersionReaders = [apiVersionReader];
4646
}
4747
else
4848
{

src/Common/src/Common/MediaTypeApiVersionReaderBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Asp.Versioning;
2424
using System.Runtime.CompilerServices;
2525
using System.Text.RegularExpressions;
2626
#if NETFRAMEWORK
27-
using FrozenSet = HashSet<String>;
27+
using FrozenSet = HashSet<string>;
2828
#else
2929
using FrozenSet = FrozenSet<StringSegment>;
3030
#endif

src/Common/test/Common.Mvc.Tests/Conventions/ApiVersionConventionBuilderTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
//// Ignore Spelling: Dtime
4+
35
namespace Asp.Versioning.Conventions
46
{
57
#if NETFRAMEWORK

src/Common/test/Common.Mvc.Tests/Conventions/ControllerApiVersionConventionBuilderTTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private sealed class TestControllerApiVersionConventionBuilder : ControllerApiVe
7474
internal ActionApiVersionConventionBuilderCollection<ControllerBase> ProtectedActionBuilders => ActionBuilders;
7575
}
7676

77+
#pragma warning disable IDE0079
7778
#pragma warning disable CA1812
7879

7980
#if !NETFRAMEWORK

src/Common/test/Common.Mvc.Tests/Conventions/DefaultControllerNameConventionTest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public static IEnumerable<object[]> NormalizeNameData
3535
{
3636
get
3737
{
38-
return new[]
38+
return new object[][]
3939
{
4040
#if NETFRAMEWORK
41-
new object[] { "ValuesController" },
42-
new object[] { "Values2Controller" },
41+
["ValuesController"],
42+
["Values2Controller"],
4343
#else
44-
new object[] { "Values" },
45-
new object[] { "Values2" },
44+
["Values"],
45+
["Values2"],
4646
#endif
4747
};
4848
}

src/Common/test/Common.Mvc.Tests/Conventions/GroupedControllerNameConventionTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ public static IEnumerable<object[]> NormalizeNameData
3737
{
3838
get
3939
{
40-
return new[]
40+
return new object[][]
4141
{
42-
new object[] { "Values" },
42+
["Values"],
4343
#if NETFRAMEWORK
44-
new object[] { "ValuesController2" },
44+
["ValuesController2"],
4545
#else
46-
new object[] { "Values2" },
46+
["Values2"],
4747
#endif
4848
};
4949
}

src/Common/test/Common.Mvc.Tests/Conventions/OriginalControllerNameConventionTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public static IEnumerable<object[]> NormalizeNameData
3535
{
3636
get
3737
{
38-
return new[]
38+
return new object[][]
3939
{
40-
new object[] { "Values" },
41-
new object[] { "Values2" },
40+
["Values"],
41+
["Values2"],
4242
#if NETFRAMEWORK
43-
new object[] { "ValuesController2" },
43+
["ValuesController2"],
4444
#endif
4545
};
4646
}

src/Common/test/Common.OData.ApiExplorer.Tests/Conventions/ODataActionQueryOptionsConventionBuilderTTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ public void action_should_call_action_on_controller_builder()
239239
controllerBuilder.Verify( cb => cb.Action( method ), Once() );
240240
}
241241

242+
#pragma warning disable IDE0079
242243
#pragma warning disable CA1034 // Nested types should not be visible
243244

244245
public sealed class TestController : ControllerBase

src/Common/test/Common.OData.ApiExplorer.Tests/Conventions/ODataActionQueryOptionsConventionBuilderTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ public void action_should_call_action_on_controller_builder()
239239
controllerBuilder.Verify( cb => cb.Action( method ), Once() );
240240
}
241241

242+
#pragma warning disable IDE0079
242243
#pragma warning disable CA1034 // Nested types should not be visible
243244

244245
public sealed class TestController : ControllerBase

src/Common/test/Common.OData.ApiExplorer.Tests/Conventions/ODataQueryOptionsConventionBuilderTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3-
namespace Asp.Versioning.Conventions;
3+
//// Ignore Spelling: Dtime
44

5+
namespace Asp.Versioning.Conventions;
56

67
#if NETFRAMEWORK
78
using Microsoft.AspNet.OData;
@@ -112,6 +113,7 @@ private sealed class TestODataQueryOptionsConventionBuilder : ODataQueryOptionsC
112113
internal new IList<IODataQueryOptionsConvention> Conventions => base.Conventions;
113114
}
114115

116+
#pragma warning disable IDE0079
115117
#pragma warning disable CA1034 // Nested types should not be visible
116118

117119
public sealed class StubController : ODataController

src/Common/test/Common.OData.ApiExplorer.Tests/OData/Company.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
4+
#pragma warning disable CA1002 // Do not expose generic lists
5+
#pragma warning disable CA2227 // Collection properties should be read only
6+
37
namespace Asp.Versioning.OData;
48

59
public class Company
@@ -8,11 +12,7 @@ public class Company
812

913
public Company ParentCompany { get; set; }
1014

11-
#pragma warning disable CA1002 // Do not expose generic lists
12-
#pragma warning disable CA2227 // Collection properties should be read only
1315
public List<Company> Subsidiaries { get; set; }
14-
#pragma warning restore CA2227 // Collection properties should be read only
15-
#pragma warning restore CA1002 // Do not expose generic lists
1616

1717
public string Name { get; set; }
1818

0 commit comments

Comments
 (0)