Skip to content

Commit 968e417

Browse files
Fix all code analysis issues generated by the .NET 7.0.101 SDK
1 parent 996dd65 commit 968e417

File tree

69 files changed

+244
-35
lines changed

Some content is hidden

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

69 files changed

+244
-35
lines changed

src/Abstractions/src/Asp.Versioning.Abstractions/AdvertiseApiVersionsAttribute.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
4+
#pragma warning disable CA1019
5+
#pragma warning disable CA1033
6+
#pragma warning disable CA1813
7+
38
namespace Asp.Versioning;
49

510
using static System.AttributeTargets;

src/Abstractions/src/Asp.Versioning.Abstractions/ApiVersion.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,11 @@ public virtual int CompareTo( ApiVersion? other )
341341
public virtual string ToString( string? format, IFormatProvider? formatProvider )
342342
{
343343
var provider = ApiVersionFormatProvider.GetInstance( formatProvider );
344+
#pragma warning disable IDE0079
345+
#pragma warning disable CA1062 // Validate arguments of public methods
344346
return provider.Format( format, this, formatProvider );
347+
#pragma warning restore CA1062 // Validate arguments of public methods
348+
#pragma warning restore IDE0079
345349
}
346350

347351
private static string? ValidateStatus( string? status, Func<string?, bool> isValid )

src/Abstractions/src/Asp.Versioning.Abstractions/ApiVersionAttribute.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
4+
#pragma warning disable CA1019
5+
#pragma warning disable CA1033
6+
#pragma warning disable CA1813
7+
38
namespace Asp.Versioning;
49

510
using static System.AttributeTargets;

src/Abstractions/src/Asp.Versioning.Abstractions/IApiVersionNeutral.cs

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

3+
#pragma warning disable IDE0079
4+
#pragma warning disable CA1040
5+
36
namespace Asp.Versioning;
47

58
/// <summary>

src/Abstractions/src/Asp.Versioning.Abstractions/LinkHeaderValue.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,13 @@ public IEnumerator<KeyValuePair<StringSegment, StringSegment>> GetEnumerator()
572572
}
573573

574574
// REF: https://datatracker.ietf.org/doc/html/rfc8288#appendix-B.3 #9
575+
#pragma warning disable CA1308 // Normalize strings to uppercase (all ascii and should normalize to lowercase)
575576
#if NETSTANDARD1_0
576577
var key = remaining.Substring( start, end - start ).ToLowerInvariant();
577578
#else
578579
var key = new StringSegment( remaining.Substring( start, end - start ).ToLowerInvariant() );
579580
#endif
581+
#pragma warning restore CA1308 // Normalize strings to uppercase
580582

581583
start = end;
582584
ConsumeWhitespace();

src/Abstractions/src/Asp.Versioning.Abstractions/MapToApiVersionAttribute.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
4+
#pragma warning disable CA1019
5+
#pragma warning disable CA1033
6+
#pragma warning disable CA1813
7+
38
namespace Asp.Versioning;
49

510
using static System.AttributeTargets;

src/Abstractions/src/Asp.Versioning.Abstractions/net7.0/ApiVersion.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public partial class ApiVersion : ISpanFormattable
1111
public virtual bool TryFormat( Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider )
1212
{
1313
var instance = ApiVersionFormatProvider.GetInstance( provider );
14+
#pragma warning disable IDE0079
15+
#pragma warning disable CA1062 // Validate arguments of public methods
1416
return instance.TryFormat( destination, out charsWritten, format, this, provider );
17+
#pragma warning restore CA1062 // Validate arguments of public methods
18+
#pragma warning restore IDE0079
1519
}
1620
}

src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/V3/SuppliersController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

33
#pragma warning disable IDE0060 // Remove unused parameter
4+
#pragma warning disable IDE0079 // Remove unnecessary suppression
45
#pragma warning disable SA1625 // Element documentation should not be copied and pasted
56

67
namespace Asp.Versioning.Simulators.V3;
8+
#pragma warning restore IDE0079 // Remove unnecessary suppression
79

810
using Asp.Versioning.OData;
911
using Asp.Versioning.Simulators.Models;

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/HttpServerFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract partial class HttpServerFixture
1818
{
1919
private string visualizationUrl;
2020

21-
public string DirectedGraphVisualizationUrl =>
21+
internal string DirectedGraphVisualizationUrl =>
2222
visualizationUrl ??= GenerateEndpointDirectedGraph( Server.Services );
2323

2424
protected virtual void OnConfigurePartManager( ApplicationPartManager partManager ) =>

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/Controllers/WeatherForecastsController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

33
#pragma warning disable IDE0060 // Remove unused parameter
4+
#pragma warning disable IDE0079
45
#pragma warning disable CA1822 // Mark members as static
56

67
namespace Asp.Versioning.OData.Basic.Controllers;

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/given versioned batch middleware/when using a query string.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable CA2000 // Dispose objects before losing scope
34

45
namespace given_versioned_batch_middleware;
56

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/given versioned batch middleware/when using a url segment.cs

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

3+
#pragma warning disable IDE0079
4+
#pragma warning disable CA2000 // Dispose objects before losing scope
35

46
namespace given_versioned_batch_middleware;
57

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Configuration/CustomerModelConfiguration.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ private static EntityTypeConfiguration<Customer> ConfigureCurrent( ODataModelBui
2525

2626
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
2727
{
28+
if ( builder == null )
29+
{
30+
throw new ArgumentNullException( nameof( builder ) );
31+
}
32+
33+
if ( apiVersion == null )
34+
{
35+
throw new ArgumentNullException( nameof( apiVersion ) );
36+
}
37+
2838
switch ( apiVersion.MajorVersion )
2939
{
3040
case 1:

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Configuration/OrderModelConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ private static EntityTypeConfiguration<Order> ConfigureCurrent( ODataModelBuilde
2222

2323
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
2424
{
25+
if ( builder == null )
26+
{
27+
throw new ArgumentNullException( nameof( builder ) );
28+
}
29+
2530
if ( supportedApiVersion == null || supportedApiVersion == apiVersion )
2631
{
2732
ConfigureCurrent( builder );

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Configuration/PersonModelConfiguration.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ private static EntityTypeConfiguration<Person> ConfigureCurrent( ODataModelBuild
2525

2626
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
2727
{
28+
if ( builder == null )
29+
{
30+
throw new ArgumentNullException( nameof( builder ) );
31+
}
32+
33+
if ( apiVersion == null )
34+
{
35+
throw new ArgumentNullException( nameof( apiVersion ) );
36+
}
37+
2838
switch ( apiVersion.MajorVersion )
2939
{
3040
case 1:

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Configuration/WeatherForecastModelConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ private static EntityTypeConfiguration<WeatherForecast> ConfigureCurrent( ODataM
2222

2323
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
2424
{
25+
if ( builder == null )
26+
{
27+
throw new ArgumentNullException( nameof( builder ) );
28+
}
29+
2530
if ( supportedApiVersion == null || supportedApiVersion == apiVersion )
2631
{
2732
ConfigureCurrent( builder );

src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/ApiExplorer/PartialODataDescriptionProvider.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ protected ODataApiExplorerOptions Options
8787
/// <inheritdoc />
8888
public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context )
8989
{
90+
if ( context == null )
91+
{
92+
throw new ArgumentNullException( nameof( context ) );
93+
}
94+
9095
var results = FilterResults( context.Results, Conventions );
9196

9297
if ( results.Count == 0 )
@@ -120,6 +125,11 @@ public virtual void OnProvidersExecuting( ApiDescriptionProviderContext context
120125
/// <inheritdoc />
121126
public virtual void OnProvidersExecuted( ApiDescriptionProviderContext context )
122127
{
128+
if ( context == null )
129+
{
130+
throw new ArgumentNullException( nameof( context ) );
131+
}
132+
123133
var actions = context.Actions;
124134

125135
for ( var i = 0; i < actions.Count; i++ )

src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/ApiExplorer/SubstitutedModelMetadata.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
34
#pragma warning disable CA1812
45

56
namespace Asp.Versioning.ApiExplorer;

src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/DependencyInjection/IApiVersioningBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ private static void AddApiExplorerServices( IApiVersioningBuilder builder )
6565
services.Replace( Singleton<IOptionsFactory<ApiExplorerOptions>, ODataApiExplorerOptionsAdapter>() );
6666
}
6767

68+
#pragma warning disable IDE0079
6869
#pragma warning disable CA1812
6970

7071
private sealed class ODataApiExplorerOptionsAdapter : IOptionsFactory<ApiExplorerOptions>

src/AspNetCore/OData/src/Asp.Versioning.OData/OData/ODataApiVersionCollectionProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
34
#pragma warning disable CA1812
45

56
namespace Asp.Versioning.OData;

src/AspNetCore/OData/src/Asp.Versioning.OData/OData/ODataMultiModelApplicationModelProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0079
34
#pragma warning disable CA1812
45

56
namespace Asp.Versioning.OData;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ private static ApiDescription NewApiDescription( Type controllerType, Type respo
637637
}
638638

639639
#pragma warning disable IDE0060 // Remove unused parameter
640+
#pragma warning disable CA1034 // Nested types should not be visible
640641

641642
public class SinglePartController : ODataController
642643
{

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/AllConfigurations.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public class AllConfigurations : IModelConfiguration
1313
/// <inheritdoc />
1414
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
1515
{
16+
if ( builder == null )
17+
{
18+
throw new ArgumentNullException( nameof( builder ) );
19+
}
20+
1621
builder.Function( "GetSalesTaxRate" ).Returns<double>().Parameter<int>( "PostalCode" );
1722
}
1823
}

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/OrderModelConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class OrderModelConfiguration : IModelConfiguration
1414
/// <inheritdoc />
1515
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
1616
{
17+
if ( builder == null )
18+
{
19+
throw new ArgumentNullException( nameof( builder ) );
20+
}
21+
1722
var order = builder.EntitySet<Order>( "Orders" ).EntityType.HasKey( o => o.Id );
1823

1924
if ( apiVersion < ApiVersions.V2 )

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/PersonModelConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class PersonModelConfiguration : IModelConfiguration
1414
/// <inheritdoc />
1515
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
1616
{
17+
if ( builder == null )
18+
{
19+
throw new ArgumentNullException( nameof( builder ) );
20+
}
21+
1722
var person = builder.EntitySet<Person>( "People" ).EntityType.HasKey( p => p.Id );
1823

1924
if ( apiVersion < ApiVersions.V3 )

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/ProductConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class ProductConfiguration : IModelConfiguration
1414
/// <inheritdoc />
1515
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
1616
{
17+
if ( builder == null )
18+
{
19+
throw new ArgumentNullException( nameof( builder ) );
20+
}
21+
1722
if ( apiVersion < ApiVersions.V3 )
1823
{
1924
return;

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/SupplierConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public class SupplierConfiguration : IModelConfiguration
1414
/// <inheritdoc />
1515
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix )
1616
{
17+
if ( builder == null )
18+
{
19+
throw new ArgumentNullException( nameof( builder ) );
20+
}
21+
1722
if ( apiVersion < ApiVersions.V3 )
1823
{
1924
return;

src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Models/Supplier.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ public class Supplier
88

99
public string Name { get; set; }
1010

11+
#pragma warning disable CA2227 // Collection properties should be read only
1112
public ICollection<Product> Products { get; set; }
13+
#pragma warning restore CA2227 // Collection properties should be read only
1214
}

src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/ApplicationModels/ODataControllerSpecificationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public void is_satisfied_by_should_return_expected_value( Type controllerType, b
2929
result.Should().Be( expected );
3030
}
3131

32+
#pragma warning disable IDE0079
3233
#pragma warning disable CA1812
3334

3435
private sealed class NormalODataController : ODataController

src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Controllers/VersionedMetadataControllerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public async Task options_should_return_expected_headers()
3434
response.Content.Headers.Allow.Should().BeEquivalentTo( "GET", "OPTIONS" );
3535
}
3636

37+
#pragma warning disable IDE0079
3738
#pragma warning disable CA1812
3839
#pragma warning disable CA1822 // Mark members as static
3940

src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/OData/ModelConfigurationFeatureProviderTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void populate_feature_should_discover_valid_model_configurations()
3232
}
3333
}
3434

35+
#pragma warning disable IDE0079
3536
#pragma warning disable CA1812
3637
#pragma warning disable SA1402 // File may only contain a single type
3738
#pragma warning disable SA1403 // File may only contain a single namespace
@@ -43,7 +44,7 @@ internal struct ValueTypeModelConfiguration : IModelConfiguration
4344
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) { }
4445
}
4546

46-
internal class PrivateModelConfiguration : IModelConfiguration
47+
internal sealed class PrivateModelConfiguration : IModelConfiguration
4748
{
4849
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) { }
4950
}
@@ -53,12 +54,12 @@ public abstract class AbstractModelConfiguration : IModelConfiguration
5354
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) { }
5455
}
5556

56-
public class GenericModelConfiguration<T> : IModelConfiguration
57+
public sealed class GenericModelConfiguration<T> : IModelConfiguration
5758
{
5859
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) { }
5960
}
6061

61-
public class PublicModelConfiguration : IModelConfiguration
62+
public sealed class PublicModelConfiguration : IModelConfiguration
6263
{
6364
public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) { }
6465
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void applied_to_action_should_return_true()
5252
action.Selectors.Should().HaveCount( 1 );
5353
}
5454

55+
#pragma warning disable IDE0079
5556
#pragma warning disable CA1812
5657

5758
private sealed class AnotherVersionedMetadataController : VersionedMetadataController

src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/ApiVersionMetadataCollationCollection.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ ApiVersionMetadata IList<ApiVersionMetadata>.this[int index]
4747
/// <inheritdoc />
4848
public int Count => items.Count;
4949

50+
#pragma warning disable IDE0079
51+
#pragma warning disable CA1033 // Interface methods should be callable by child types
5052
bool ICollection<ApiVersionMetadata>.IsReadOnly => ( (ICollection<ApiVersionMetadata>) items ).IsReadOnly;
53+
#pragma warning restore CA1033 // Interface methods should be callable by child types
54+
#pragma warning restore IDE0079
5155

5256
/// <inheritdoc />
5357
public void Add( ApiVersionMetadata item ) => Insert( Count, item, default );

src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiVersioningFeature.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ public string? RawRequestedApiVersion
5858
{
5959
0 => default,
6060
1 => values[0],
61+
#pragma warning disable IDE0079
62+
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
6163
_ => throw NewAmbiguousApiVersionException( values ),
64+
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
65+
#pragma warning restore IDE0079
6266
};
6367
}
6468
set

0 commit comments

Comments
 (0)