Skip to content

Commit 250e954

Browse files
committed
[fix] analyzer warnings
1 parent 4d09796 commit 250e954

12 files changed

Lines changed: 50 additions & 46 deletions

File tree

src/SampleApps/SampleApp.Api/Setup/IocRegistrations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public static class IocRegistrations
88
{
99
private static IConfiguration Configuration { get; set; } = null!;
1010

11-
public static IDIContainerProvider RegisterAll(this IDIContainerProvider provider, IServiceCollection services)
11+
public static IDIContainerProvider RegisterAll(this IDIContainerProvider provider)
1212
{
1313
provider.RegisterCustomConfiguration(config => Configuration = config)
14-
.RegisterSimplifyWeb(Configuration);
14+
.RegisterSimplifyWeb(Configuration);
1515

1616
return provider;
1717
}

src/SampleApps/SampleApp.Api/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
DIContainer.Current = new SimpleInjectorDIProvider();
99

1010
DIContainer.Current
11-
.RegisterAll(builder.Services)
11+
.RegisterAll()
1212
.Verify();
1313

1414
var app = builder.Build();

src/SampleApps/SampleApp.Classic/Controllers/Accounts/LoginController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override async Task<ControllerResponse> Invoke()
2626
{
2727
var claims = new List<Claim>
2828
{
29-
new Claim(ClaimTypes.Name, Model.UserName)
29+
new(ClaimTypes.Name, Model.UserName)
3030
};
3131

3232
var id = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);

src/Simplify.Web.Tests/Benchmark/ExpandoVsDictionaryBenchmark.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static ExpandoObject ToExpando(IDictionary<string, object> dictionary)
9595
return expando;
9696
}
9797

98-
private void TestDynamic(dynamic list, int numValues)
98+
private static void TestDynamic(dynamic list, int numValues)
9999
{
100100
for (var i = 0; i < numValues; i++)
101101
{
@@ -104,7 +104,7 @@ private void TestDynamic(dynamic list, int numValues)
104104
}
105105
}
106106

107-
private void TestDictionary(IDictionary<string, object> list, int numValues)
107+
private static void TestDictionary(IDictionary<string, object> list, int numValues)
108108
{
109109
for (var i = 0; i < numValues; i++)
110110
{
@@ -113,7 +113,7 @@ private void TestDictionary(IDictionary<string, object> list, int numValues)
113113
}
114114
}
115115

116-
private IDictionary<string, object> CreateAndFillExpando(int numValues)
116+
private static IDictionary<string, object> CreateAndFillExpando(int numValues)
117117
{
118118
var expandoDict = (IDictionary<string, object>)new ExpandoObject();
119119

@@ -123,7 +123,7 @@ private IDictionary<string, object> CreateAndFillExpando(int numValues)
123123
return expandoDict;
124124
}
125125

126-
private IDictionary<string, object> CreateAndFillDictionary(int numValues)
126+
private static Dictionary<string, object> CreateAndFillDictionary(int numValues)
127127
{
128128
var dictionary = new Dictionary<string, object>();
129129

src/Simplify.Web.Tests/Controllers/Execution/PreviousPageUrlUpdaterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Simplify.Web.Tests.Controllers.Execution;
1111
[TestFixture]
1212
public class PreviousPageUrlUpdaterTests
1313
{
14-
private readonly IReadOnlyList<IMatchedController> _controllers = new List<IMatchedController>();
14+
private readonly IReadOnlyList<IMatchedController> _controllers = [];
1515

1616
private PreviousPageUrlUpdater _updater = null!;
1717

src/Simplify.Web.Tests/Controllers/Execution/WorkOrder/ExecutionWorkOrderBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public void Build()
4141
Assert.That(result.Controllers[4].Controller.ExecParameters!.RunPriority, Is.EqualTo(5));
4242
}
4343

44-
private IMatchedController CreateController(int priority) =>
44+
private static IMatchedController CreateController(int priority) =>
4545
Mock.Of<IMatchedController>(x => x.Controller.ExecParameters == new ControllerExecParameters(null, priority));
4646
}

src/Simplify.Web.Tests/Controllers/Security/Rules/RoleAuthorizationRuleTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public void IsViolated_AuthorizationRequiredWithGroupAuthorizedNoGroups_True()
2222
{
2323
// Arrange
2424

25-
var security = new ControllerSecurity(true, new List<string>
26-
{
25+
var security = new ControllerSecurity(true,
26+
[
2727
"Admin",
2828
"User"
29-
});
29+
]);
3030

3131
var claims = new List<Claim>
3232
{
@@ -48,10 +48,10 @@ public void IsViolated_AuthorizationRequiredWithGroupAuthorizedNotInGroup_True()
4848
{
4949
// Arrange
5050

51-
var security = new ControllerSecurity(true, new List<string>
52-
{
51+
var security = new ControllerSecurity(true,
52+
[
5353
"Admin"
54-
});
54+
]);
5555

5656
var claims = new List<Claim>
5757
{
@@ -74,11 +74,11 @@ public void IsViolated_AuthorizationRequiredWithGroupAuthorizedInGroup_False()
7474
{
7575
// Arrange
7676

77-
var security = new ControllerSecurity(true, new List<string>
78-
{
77+
var security = new ControllerSecurity(true,
78+
[
7979
"Admin",
8080
"User"
81-
});
81+
]);
8282

8383
var claims = new List<Claim>
8484
{
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
namespace Simplify.Web.Tests.Controllers.V2.Metadata.MetadataTests.TestTypes;
22

3+
#pragma warning disable CA1822 // Mark members as static
4+
35
public class BadReturnTypeController : Controller2
46
{
57
public object? Invoke() => null;
6-
}
8+
}
9+
10+
#pragma warning restore CA1822 // Mark members as static

src/Simplify.Web.Tests/Responses/FileTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Initialize()
2020
{
2121
_context = new Mock<IWebContext>();
2222
_responseWriter = new Mock<IResponseWriter>();
23-
_headerDictionary = new HeaderDictionary();
23+
_headerDictionary = [];
2424

2525
_context.SetupGet(x => x.Response.Headers).Returns(_headerDictionary);
2626
_context.Setup(x => x.Response.Body.Write(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>()));
@@ -31,7 +31,7 @@ public async Task Process_NormalData_FileSent()
3131
{
3232
// Arrange
3333

34-
var data = new byte[] { 13 };
34+
var data = "\r"u8.ToArray();
3535
var file = new Mock<File>("Foo.txt", "application/example", data, 200) { CallBase = true };
3636

3737
file.SetupGet(x => x.Context).Returns(_context.Object);

src/Simplify.Web/Model/Validation/Attributes/MaxAttribute.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ public override void Validate(object? value, PropertyInfo propertyInfo, IDIResol
105105
$"Property '{propertyInfo.Name}' required maximum value is {MaxValue}, actual value: {value}");
106106
}
107107

108+
private static IComparable ConvertToIComparable(object value)
109+
{
110+
if (value is not IComparable comparableValue)
111+
throw new ArgumentException($"The type of object value must be inherited from {typeof(IComparable)}");
112+
113+
return comparableValue;
114+
}
115+
108116
private void ValidateTypesMatching(object value)
109117
{
110118
if (value.GetType() != OperandType)
@@ -117,12 +125,4 @@ private IComparable ConvertToOperandComparableType(object value)
117125

118126
return ConvertToIComparable(convertedValue);
119127
}
120-
121-
private IComparable ConvertToIComparable(object value)
122-
{
123-
if (value is not IComparable comparableValue)
124-
throw new ArgumentException($"The type of object value must be inherited from {typeof(IComparable)}");
125-
126-
return comparableValue;
127-
}
128128
}

0 commit comments

Comments
 (0)