Skip to content

Commit c3f8e56

Browse files
#515 Optimise dependencies to remove polyfil (#516)
* #515 make STJ only included for net standard * Moved to global package refs & add suppressions * Make System.ComponentModel.Annotations oonly for net std * Styling fixes. --------- Co-authored-by: Steve Smith <steve@kentsmiths.com>
1 parent 7396d73 commit c3f8e56

22 files changed

+137
-117
lines changed

Directory.Packages.props

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@
1818
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13" />
1919
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.13" />
2020
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
21-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
2221
<PackageVersion Include="Moq" Version="4.18.4" />
2322
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
2423
<PackageVersion Include="protobuf-net" Version="3.2.26" />
25-
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.17.0.82934" />
2624
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
2725
<PackageVersion Include="System.Text.Json" Version="8.0.2" />
2826
<PackageVersion Include="Utf8Json" Version="1.3.7" />
2927
<PackageVersion Include="xunit" Version="2.7.0" />
3028
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
3129
</ItemGroup>
30+
31+
<ItemGroup>
32+
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
33+
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.17.0.82934" PrivateAssets="All" />
34+
</ItemGroup>
3235
</Project>

benchmarks/SmartEnum.Benchmarks/EqualsBenchmarks.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
namespace Ardalis.SmartEnum.Benchmarks
22
{
33
using BenchmarkDotNet.Attributes;
4+
using System.Diagnostics.CodeAnalysis;
45

56
[Config(typeof(Config))]
7+
[SuppressMessage("Major Bug", "S1764:Identical expressions should not be used on both sides of operators", Justification = "<Pending>")]
68
public class EqualsBenchmarks
79
{
810
////////////////////////////////////////////////////////////////////////////////

benchmarks/SmartEnum.Benchmarks/SerializationBenchmarks.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Ardalis.SmartEnum.Benchmarks
22
{
3+
using System.Diagnostics.CodeAnalysis;
34
using System.IO;
45
using BenchmarkDotNet.Attributes;
56

@@ -68,6 +69,7 @@ public sealed class TestSmartEnumValueClass
6869
static Stream valueProtoBufDeserializeStream;
6970

7071
[GlobalSetup]
72+
[SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>")]
7173
public void GlobalSetup()
7274
{
7375
global::Utf8Json.Resolvers.CompositeResolver.Register(

benchmarks/SmartEnum.Benchmarks/SwitchBenchmarks.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
namespace Ardalis.SmartEnum.Benchmarks
22
{
33
using System;
4+
using System.Diagnostics.CodeAnalysis;
45
using BenchmarkDotNet.Attributes;
56

67
[Config(typeof(Config))]
8+
[SuppressMessage("Major Bug", "S2583:Conditionally executed code should be reachable", Justification = "<Pending>")]
9+
[SuppressMessage("Major Code Smell", "S112:General or reserved exceptions should never be thrown", Justification = "<Pending>")]
710
public class SwitchBenchmarks
811
{
912
////////////////////////////////////////////////////////////////////////////////

benchmarks/SmartEnum.Benchmarks/TestEnums.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
13
namespace Ardalis.SmartEnum.Benchmarks
24
{
35
////////////////////////////////////////////////////////////////////////////////
46
// Enum
57

68
[global::ProtoBuf.ProtoContract]
9+
[SuppressMessage("Minor Code Smell", "S2344:Enumeration type names should not have \"Flags\" or \"Enum\" suffixes", Justification = "<Pending>")]
710
public enum TestEnum
811
{
912
[global::ProtoBuf.ProtoEnum]

src/SmartEnum.AutoFixture/SmartEnum.AutoFixture.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
</PropertyGroup>
1717
<ItemGroup>
1818
<PackageReference Include="AutoFixture" />
19-
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
20-
<PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="All" />
2119
</ItemGroup>
2220
<ItemGroup>
2321
<None Include="$(SolutionDir)img\icon.png" Pack="true" Visible="false" PackagePath="" />

src/SmartEnum.Dapper/DapperSmartEnum.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace Ardalis.SmartEnum.Dapper
22
{
3-
//using global::Dapper;
43
using System;
54

65
/// <summary>

src/SmartEnum.JsonNet/SmartEnum.JsonNet.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<PackageId>Ardalis.SmartEnum.JsonNet</PackageId>
44
<Title>Ardalis.SmartEnum.JsonNet</Title>
@@ -15,8 +15,6 @@
1515
</PropertyGroup>
1616
<ItemGroup>
1717
<PackageReference Include="Newtonsoft.Json" />
18-
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
19-
<PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="All" />
2018
</ItemGroup>
2119
<ItemGroup>
2220
<None Include="$(SolutionDir)img\icon.png" Pack="true" Visible="false" PackagePath="" />

src/SmartEnum.MessagePack/SmartEnum.MessagePack.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
</PropertyGroup>
1616
<ItemGroup>
1717
<PackageReference Include="MessagePack" />
18-
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
19-
<PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="All" />
2018
</ItemGroup>
2119
<ItemGroup>
2220
<None Include="$(SolutionDir)img\icon.png" Pack="true" Visible="false" PackagePath="" />

src/SmartEnum.ModelBinding/SmartEnumModelBinder.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
3636
if (methodInfo.Name == "FromName")
3737
{
3838
ParameterInfo[] methodsParams = methodInfo.GetParameters();
39-
if (methodsParams.Length == 2)
39+
if (methodsParams.Length == 2 &&
40+
methodsParams[0].ParameterType == typeof(string) &&
41+
methodsParams[1].ParameterType == typeof(bool))
4042
{
41-
if (methodsParams[0].ParameterType == typeof(string) && methodsParams[1].ParameterType == typeof(bool))
42-
{
43-
var enumObj = methodInfo.Invoke(null, new object[] { enumKeyName, true });
44-
bindingContext.Result = ModelBindingResult.Success(enumObj);
45-
return Task.CompletedTask;
46-
}
43+
var enumObj = methodInfo.Invoke(null, new object[] { enumKeyName, true });
44+
bindingContext.Result = ModelBindingResult.Success(enumObj);
45+
return Task.CompletedTask;
4746
}
4847
}
4948
}

0 commit comments

Comments
 (0)