Skip to content

Commit 1f994aa

Browse files
authored
removed Math.Abs from id calculation (#33)
1 parent b4aaa48 commit 1f994aa

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Controls/src/BindingSourceGen/BindingSourceGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3939
{
4040

4141
var fileName = $"{binding.Location.FilePath}/GeneratedBindableObjectExtensions-{binding.Location.Line}-{binding.Location.Column}.g.cs";
42-
spc.AddSource(fileName, BindingCodeWriter.GenerateBinding(binding, (uint)Math.Abs(binding.Location.GetHashCode())));
42+
spc.AddSource(fileName, BindingCodeWriter.GenerateBinding(binding, (uint)binding.Location.GetHashCode()));
4343
});
4444
}
4545

src/Controls/tests/BindingSourceGen.UnitTests/IntegrationTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void GenerateSimpleBinding()
1414
""";
1515

1616
var result = SourceGenHelpers.Run(source);
17-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
17+
var id = (uint)result.Binding!.Location.GetHashCode();
1818

1919
AssertExtensions.AssertNoDiagnostics(result);
2020
AssertExtensions.CodeIsEqual(
@@ -109,7 +109,7 @@ public class B
109109
""";
110110

111111
var result = SourceGenHelpers.Run(source);
112-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
112+
var id = (uint)result.Binding!.Location.GetHashCode();
113113
AssertExtensions.AssertNoDiagnostics(result);
114114
AssertExtensions.CodeIsEqual(
115115
$$"""
@@ -212,7 +212,7 @@ public class B
212212
""";
213213

214214
var result = SourceGenHelpers.Run(source);
215-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
215+
var id = (uint)result.Binding!.Location.GetHashCode();
216216
AssertExtensions.AssertNoDiagnostics(result);
217217
AssertExtensions.CodeIsEqual(
218218
$$"""
@@ -420,7 +420,7 @@ public class C
420420
public void GenerateSimpleBindingWhenNullableDisabledAndPropertyNullable(string source)
421421
{
422422
var result = SourceGenHelpers.Run(source);
423-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
423+
var id = (uint)result.Binding!.Location.GetHashCode();
424424
AssertExtensions.AssertNoDiagnostics(result);
425425
AssertExtensions.CodeIsEqual(
426426
$$"""
@@ -537,7 +537,7 @@ public class D {
537537
""";
538538

539539
var result = SourceGenHelpers.Run(source);
540-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
540+
var id = (uint)result.Binding!.Location.GetHashCode();
541541
AssertExtensions.AssertNoDiagnostics(result);
542542
AssertExtensions.CodeIsEqual(
543543
$$"""
@@ -654,7 +654,7 @@ public class MyPropertyClass
654654
""";
655655

656656
var result = SourceGenHelpers.Run(source);
657-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
657+
var id = (uint)result.Binding!.Location.GetHashCode();
658658

659659
AssertExtensions.AssertNoDiagnostics(result);
660660
AssertExtensions.CodeIsEqual(
@@ -777,7 +777,7 @@ public class MyPropertyClass
777777
""";
778778

779779
var result = SourceGenHelpers.Run(source);
780-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
780+
var id = (uint)result.Binding!.Location.GetHashCode();
781781

782782
AssertExtensions.AssertNoDiagnostics(result);
783783
AssertExtensions.CodeIsEqual(
@@ -887,7 +887,7 @@ public class Wrapper
887887
""";
888888

889889
var result = SourceGenHelpers.Run(source);
890-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
890+
var id = (uint)result.Binding!.Location.GetHashCode();
891891

892892
AssertExtensions.AssertNoDiagnostics(result);
893893
AssertExtensions.CodeIsEqual(
@@ -993,7 +993,7 @@ public class MyPropertyClass
993993
""";
994994

995995
var result = SourceGenHelpers.Run(source);
996-
var id = Math.Abs(result.Binding!.Location.GetHashCode());
996+
var id = (uint)result.Binding!.Location.GetHashCode();
997997

998998
AssertExtensions.AssertNoDiagnostics(result);
999999
AssertExtensions.CodeIsEqual(

0 commit comments

Comments
 (0)