Skip to content

Commit 81fe0f1

Browse files
committed
Add .NET 10 support, update Roslyn, modernize tests
1 parent 3048aaf commit 81fe0f1

12 files changed

Lines changed: 75 additions & 80 deletions

Directory.Packages.props

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
<ItemGroup>
77
<PackageVersion Include="AssemblyMetadata.Generators" Version="2.1.0" />
88
<PackageVersion Include="coverlet.collector" Version="8.0.1" />
9-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.4.0]" />
9+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.8.0]" />
1010
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
11-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
1211
<PackageVersion Include="MinVer" Version="7.0.0" />
1312
<PackageVersion Include="System.Text.Json" Version="10.0.5" />
14-
<PackageVersion Include="Verify.Xunit" Version="31.12.5" />
15-
<PackageVersion Include="xunit" Version="2.9.3" />
16-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
13+
<PackageVersion Include="Verify.XunitV3" Version="31.15.0" />
14+
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
1715
</ItemGroup>
18-
</Project>
16+
</Project>

src/Equatable.Comparers/Equatable.Comparers.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
5+
<Description>Equality comparers for sequences, dictionaries, and hash sets used by the Equatable source generator</Description>
56
</PropertyGroup>
67

78
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
55
<RootNamespace>Equatable</RootNamespace>
6+
<Description>Source generator for Equals and GetHashCode with attribute based control of equality implementation</Description>
67
</PropertyGroup>
78

89
<ItemGroup>
9-
<None Include="..\Equatable.SourceGenerator\bin\$(Configuration)\netstandard2.0\Equatable.SourceGenerator.dll" PackagePath="analyzers\dotnet\roslyn4.4\cs" Pack="true" Visible="false" />
10+
<None Include="..\Equatable.SourceGenerator\bin\$(Configuration)\netstandard2.0\Equatable.SourceGenerator.dll" PackagePath="analyzers/dotnet/roslyn4.8/cs" Pack="true" Visible="false" />
11+
<None Include="..\Equatable.SourceGenerator\Equatable.targets" PackagePath="build" Pack="true" Visible="false" />
12+
1013
</ItemGroup>
1114

1215
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; Shipped analyzer releases
2+
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
3+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; Unshipped analyzer release
2+
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
3+
4+
### New Rules
5+
6+
Rule ID | Category | Severity | Notes
7+
--------|----------|----------|------------------
8+
EQ0001 | Usage | Warning | EquatableAnalyzer
9+
EQ0002 | Usage | Warning | EquatableAnalyzer
10+
EQ0010 | Usage | Warning | EquatableAnalyzer
11+
EQ0011 | Usage | Warning | EquatableAnalyzer
12+
EQ0012 | Usage | Warning | EquatableAnalyzer
13+
EQ0013 | Usage | Warning | EquatableAnalyzer

src/Equatable.SourceGenerator/DiagnosticDescriptors.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Equatable.SourceGenerator;
44

55
internal static class DiagnosticDescriptors
66
{
7-
public static DiagnosticDescriptor MissingDictionaryEqualityAttribute => new(
7+
public static readonly DiagnosticDescriptor MissingDictionaryEqualityAttribute = new(
88
id: "EQ0001",
99
title: "Missing DictionaryEquality Attribute",
1010
messageFormat: "Property '{0}' type implements IDictionary<TKey, TValue> but does not have the [DictionaryEquality] attribute",
@@ -13,7 +13,7 @@ internal static class DiagnosticDescriptors
1313
isEnabledByDefault: true
1414
);
1515

16-
public static DiagnosticDescriptor MissingSequenceEqualityAttribute => new(
16+
public static readonly DiagnosticDescriptor MissingSequenceEqualityAttribute = new(
1717
id: "EQ0002",
1818
title: "Missing SequenceEquality or HashSetEquality Attribute",
1919
messageFormat: "Property '{0}' type implements IEnumerable<T> but does not have the [SequenceEquality] or [HashSetEquality] attribute",
@@ -22,37 +22,37 @@ internal static class DiagnosticDescriptors
2222
isEnabledByDefault: true
2323
);
2424

25-
public static DiagnosticDescriptor InvalidStringEqualityAttributeUsage => new(
25+
public static readonly DiagnosticDescriptor InvalidStringEqualityAttributeUsage = new(
2626
id: "EQ0010",
2727
title: "Invalid StringEquality Attribute Usage",
28-
messageFormat: "Invalid StringEquality attribute usage for property '{0}'. Property type is not a string",
28+
messageFormat: "Invalid StringEquality attribute usage for property '{0}'. Property type is not a string.",
2929
category: "Usage",
3030
defaultSeverity: DiagnosticSeverity.Warning,
3131
isEnabledByDefault: true
3232
);
3333

34-
public static DiagnosticDescriptor InvalidDictionaryEqualityAttributeUsage => new(
34+
public static readonly DiagnosticDescriptor InvalidDictionaryEqualityAttributeUsage = new(
3535
id: "EQ0011",
3636
title: "Invalid DictionaryEquality Attribute Usage",
37-
messageFormat: "Invalid DictionaryEquality attribute usage for property '{0}'. Property type does not implement IDictionary<TKey, TValue>",
37+
messageFormat: "Invalid DictionaryEquality attribute usage for property '{0}'. Property type does not implement IDictionary<TKey, TValue>.",
3838
category: "Usage",
3939
defaultSeverity: DiagnosticSeverity.Warning,
4040
isEnabledByDefault: true
4141
);
4242

43-
public static DiagnosticDescriptor InvalidHashSetEqualityAttributeUsage => new(
43+
public static readonly DiagnosticDescriptor InvalidHashSetEqualityAttributeUsage = new(
4444
id: "EQ0012",
4545
title: "Invalid HashSetEquality Attribute Usage",
46-
messageFormat: "Invalid HashSetEquality attribute usage for property '{0}'. Property type does not implement IEnumerable<T>",
46+
messageFormat: "Invalid HashSetEquality attribute usage for property '{0}'. Property type does not implement IEnumerable<T>.",
4747
category: "Usage",
4848
defaultSeverity: DiagnosticSeverity.Warning,
4949
isEnabledByDefault: true
5050
);
5151

52-
public static DiagnosticDescriptor InvalidSequenceEqualityAttributeUsage => new(
52+
public static readonly DiagnosticDescriptor InvalidSequenceEqualityAttributeUsage = new(
5353
id: "EQ0013",
5454
title: "Invalid SequenceEquality Attribute Usage",
55-
messageFormat: "Invalid SequenceEquality attribute usage for property '{0}'. Property type does not implement IEnumerable<T>",
55+
messageFormat: "Invalid SequenceEquality attribute usage for property '{0}'. Property type does not implement IEnumerable<T>.",
5656
category: "Usage",
5757
defaultSeverity: DiagnosticSeverity.Warning,
5858
isEnabledByDefault: true

src/Equatable.SourceGenerator/Equatable.SourceGenerator.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<ImplicitUsings>true</ImplicitUsings>
6-
<IncludeSymbols>false</IncludeSymbols>
7-
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
85
<IsRoslynComponent>true</IsRoslynComponent>
9-
<NoPackageAnalysis>true</NoPackageAnalysis>
10-
<IncludeBuildOutput>false</IncludeBuildOutput>
11-
<DevelopmentDependency>true</DevelopmentDependency>
126
<IsPackable>false</IsPackable>
137
<AnalyzerLanguage>cs</AnalyzerLanguage>
14-
<AnalyzerRoslynVersion>4.4</AnalyzerRoslynVersion>
15-
<LangVersion>latest</LangVersion>
168
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
179
</PropertyGroup>
1810

1911
<ItemGroup>
12+
<!-- https://learn.microsoft.com/en-us/visualstudio/extensibility/roslyn-version-support -->
2013
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
2114
</ItemGroup>
2215

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<ItemGroup Condition="$(Language) == 'C#' and ($(ImplicitUsings) == 'enable' or $(ImplicitUsings) == 'true')">
3+
<Using Include="Equatable.Attributes" />
4+
</ItemGroup>
5+
</Project>

src/Equatable.SourceGenerator/EquatableAnalyzer.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,12 @@ private static bool IsString(ITypeSymbol targetSymbol)
185185
};
186186
}
187187

188-
/// <summary>
189-
/// Returns true when the type either IS <c>IDictionary&lt;TKey, TValue&gt;</c>
190-
/// or implements it, covering both interface-typed and concrete-typed properties.
191-
/// </summary>
192188
private static bool ImplementsDictionary(ITypeSymbol type)
193189
{
194190
return (type is INamedTypeSymbol named && IsDictionary(named))
195191
|| type.AllInterfaces.Any(IsDictionary);
196192
}
197193

198-
/// <summary>
199-
/// Returns true when the type either IS <c>IEnumerable&lt;T&gt;</c>
200-
/// or implements it, covering both interface-typed and concrete-typed properties.
201-
/// </summary>
202194
private static bool ImplementsEnumerable(ITypeSymbol type)
203195
{
204196
return (type is INamedTypeSymbol named && IsEnumerable(named))
@@ -219,10 +211,7 @@ private static bool IsEnumerable(INamedTypeSymbol targetSymbol)
219211
ContainingNamespace:
220212
{
221213
Name: "Collections",
222-
ContainingNamespace:
223-
{
224-
Name: "System"
225-
}
214+
ContainingNamespace.Name: "System"
226215
}
227216
}
228217
};
@@ -242,10 +231,7 @@ private static bool IsDictionary(INamedTypeSymbol targetSymbol)
242231
ContainingNamespace:
243232
{
244233
Name: "Collections",
245-
ContainingNamespace:
246-
{
247-
Name: "System"
248-
}
234+
ContainingNamespace.Name: "System"
249235
}
250236
}
251237
};

test/Equatable.Entities/Equatable.Entities.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<Nullable>enable</Nullable>
77
<LangVersion>latest</LangVersion>

0 commit comments

Comments
 (0)