Skip to content

Commit 86dd268

Browse files
committed
Implementation of IComparable on the key member can be explicit.
1 parent 11c6396 commit 86dd268

68 files changed

Lines changed: 370 additions & 83 deletions

File tree

Some content is hidden

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

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
5-
<VersionPrefix>9.5.0</VersionPrefix>
5+
<VersionPrefix>9.5.1</VersionPrefix>
66
<Authors>Pawel Gerr</Authors>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ComparableCodeGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public int CompareTo(object? obj)
3535
if(obj is not ").AppendTypeFullyQualified(state.Type).Append(@" item)
3636
throw new global::System.ArgumentException(""Argument must be of type \""").AppendTypeMinimallyQualified(state.Type).Append(@"\""."", nameof(obj));
3737
38-
return this.CompareTo(item);
38+
return ((global::System.IComparable)this).CompareTo(item);
3939
}
4040
4141
/// <inheritdoc />
@@ -63,7 +63,7 @@ public int CompareTo(").AppendTypeFullyQualifiedNullAnnotated(state.Type).Append
6363
else
6464
{
6565
sb.Append(@"
66-
return this.").Append(state.KeyMember.Name).Append(".CompareTo(obj.").Append(state.KeyMember.Name).Append(");");
66+
return ((global::System.IComparable<").AppendTypeFullyQualified(state.KeyMember).Append(">)this.").Append(state.KeyMember.Name).Append(").CompareTo(obj.").Append(state.KeyMember.Name).Append(");");
6767
}
6868

6969
sb.Append(@"

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_change_conversion_from_key_Explicit1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_change_conversion_from_key_Implicit1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_change_conversion_from_key_None1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_change_conversion_to_key_Explicit1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_change_conversion_to_key_Implicit1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_change_conversion_to_key_None1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_generate_class_with_abstract_property_1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/SmartEnumSourceGeneratorTests.Should_generate_custom_delegate_with_in_parameter_1.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ partial class TestEnum :
1616
if(obj is not global::Thinktecture.Tests.TestEnum item)
1717
throw new global::System.ArgumentException("Argument must be of type \"TestEnum\".", nameof(obj));
1818

19-
return this.CompareTo(item);
19+
return ((global::System.IComparable)this).CompareTo(item);
2020
}
2121

2222
/// <inheritdoc />

0 commit comments

Comments
 (0)