diff --git a/src/StronglyTypedIds/Templates/Guid/Guid_Base.cs b/src/StronglyTypedIds/Templates/Guid/Guid_Base.cs index 200147a15..dc51f626a 100644 --- a/src/StronglyTypedIds/Templates/Guid/Guid_Base.cs +++ b/src/StronglyTypedIds/Templates/Guid/Guid_Base.cs @@ -22,3 +22,15 @@ public override bool Equals(object obj) public override string ToString() => Value.ToString(); public static bool operator ==(TESTID a, TESTID b) => a.Equals(b); public static bool operator !=(TESTID a, TESTID b) => !(a == b); + + public static TESTID Parse(string value) => new TESTID(System.Guid.Parse(value)); + public static bool TryParse(string value, out TESTID result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new TESTID(parseResult); + return true; + } + result = default; + return false; + } diff --git a/src/StronglyTypedIds/Templates/Int/Int_Base.cs b/src/StronglyTypedIds/Templates/Int/Int_Base.cs index 08ce1fca6..a24dcf60b 100644 --- a/src/StronglyTypedIds/Templates/Int/Int_Base.cs +++ b/src/StronglyTypedIds/Templates/Int/Int_Base.cs @@ -21,3 +21,15 @@ public override bool Equals(object obj) public override string ToString() => Value.ToString(); public static bool operator ==(TESTID a, TESTID b) => a.Equals(b); public static bool operator !=(TESTID a, TESTID b) => !(a == b); + + public static TESTID Parse(string value) => new TESTID(int.Parse(value)); + public static bool TryParse(string value, out TESTID result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new TESTID(parseResult); + return true; + } + result = default; + return false; + } diff --git a/src/StronglyTypedIds/Templates/Long/Long_Base.cs b/src/StronglyTypedIds/Templates/Long/Long_Base.cs index 38d9fc5a6..b5fad57cd 100644 --- a/src/StronglyTypedIds/Templates/Long/Long_Base.cs +++ b/src/StronglyTypedIds/Templates/Long/Long_Base.cs @@ -21,3 +21,15 @@ public override bool Equals(object obj) public override string ToString() => Value.ToString(); public static bool operator ==(TESTID a, TESTID b) => a.Equals(b); public static bool operator !=(TESTID a, TESTID b) => !(a == b); + + public static TESTID Parse(string value) => new TESTID(long.Parse(value)); + public static bool TryParse(string value, out TESTID result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new TESTID(parseResult); + return true; + } + result = default; + return false; + } diff --git a/src/StronglyTypedIds/Templates/NewId/NewId_Base.cs b/src/StronglyTypedIds/Templates/NewId/NewId_Base.cs index 854cd477a..1c4bd5db1 100644 --- a/src/StronglyTypedIds/Templates/NewId/NewId_Base.cs +++ b/src/StronglyTypedIds/Templates/NewId/NewId_Base.cs @@ -22,3 +22,18 @@ public override bool Equals(object obj) public override string ToString() => Value.ToString(); public static bool operator ==(TESTID a, TESTID b) => a.Equals(b); public static bool operator !=(TESTID a, TESTID b) => !(a == b); + + public static TESTID Parse(string value) => new TESTID(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out TESTID result) + { + try + { + result = new TESTID(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } diff --git a/src/StronglyTypedIds/Templates/NullableString/NullableString_Base.cs b/src/StronglyTypedIds/Templates/NullableString/NullableString_Base.cs index 94a6eaffb..b002c4412 100644 --- a/src/StronglyTypedIds/Templates/NullableString/NullableString_Base.cs +++ b/src/StronglyTypedIds/Templates/NullableString/NullableString_Base.cs @@ -29,3 +29,10 @@ public override bool Equals(object? obj) public override string? ToString() => Value; public static bool operator ==(TESTID a, TESTID b) => a.Equals(b); public static bool operator !=(TESTID a, TESTID b) => !(a == b); + + public static TESTID Parse(string? value) => new TESTID(value); + public static bool TryParse(string? value, out TESTID result) + { + result = new TESTID(value?.Trim()); + return true; + } diff --git a/src/StronglyTypedIds/Templates/String/String_Base.cs b/src/StronglyTypedIds/Templates/String/String_Base.cs index 023df780b..18352191a 100644 --- a/src/StronglyTypedIds/Templates/String/String_Base.cs +++ b/src/StronglyTypedIds/Templates/String/String_Base.cs @@ -30,3 +30,15 @@ public override bool Equals(object obj) public override string ToString() => Value; public static bool operator ==(TESTID a, TESTID b) => a.Equals(b); public static bool operator !=(TESTID a, TESTID b) => !(a == b); + + public static TESTID Parse(string value) => new TESTID(value); + public static bool TryParse(string value, out TESTID result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new TESTID(value.Trim()); + return true; + } diff --git a/test/StronglyTypedIds.IntegrationTests/GuidIdTests.cs b/test/StronglyTypedIds.IntegrationTests/GuidIdTests.cs index 2905f70e6..7f1abc5d7 100644 --- a/test/StronglyTypedIds.IntegrationTests/GuidIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/GuidIdTests.cs @@ -74,6 +74,42 @@ public void CantCreateEmptyGeneratedId1() Assert.NotEqual((object)bar, (object)foo); } + [Fact] + public void CanParseString() + { + var value = Guid.NewGuid(); + var foo = GuidId1.Parse(value.ToString()); + var bar = new GuidId1(value); + + Assert.Equal(bar, foo); + } + + [Fact] + public void ThrowWhenInvalidParseString() + { + Assert.Throws(() => GuidId1.Parse("")); + } + + [Fact] + public void CanFailTryParse() + { + var result = GuidId1.TryParse("", out _); + Assert.False(result); + } + + + [Fact] + public void CanTryParseSuccessfully() + { + var value = Guid.NewGuid(); + var result = GuidId1.TryParse(value.ToString(), out GuidId1 foo); + var bar = new GuidId1(value); + + Assert.True(result); + Assert.Equal(bar, foo); + } + + [Fact] public void CanSerializeToGuid_WithTypeConverter() { diff --git a/test/StronglyTypedIds.IntegrationTests/IntIdTests.cs b/test/StronglyTypedIds.IntegrationTests/IntIdTests.cs index e2c48be64..f0dc679a8 100644 --- a/test/StronglyTypedIds.IntegrationTests/IntIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/IntIdTests.cs @@ -64,6 +64,43 @@ public void DifferentTypesAreUnequal() Assert.NotEqual((object)bar, (object)foo); } + [Fact] + public void CanParseString() + { + var value = 1; + var foo = IntId.Parse(value.ToString()); + var bar = new IntId(value); + + Assert.Equal(bar, foo); + } + + [Fact] + public void ThrowWhenInvalidParseString() + { + Assert.Throws(() => IntId.Parse("")); + } + + [Fact] + public void CanFailTryParse() + { + var result = IntId.TryParse("", out _); + Assert.False(result); + } + + + [Fact] + public void CanTryParseSuccessfully() + { + var value = 2; + var result = IntId.TryParse(value.ToString(), out IntId foo); + var bar = new IntId(value); + + Assert.True(result); + Assert.Equal(bar, foo); + } + + + [Fact] public void CanSerializeToInt_WithNewtonsoftJsonProvider() { diff --git a/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs b/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs index b2f70dbcb..c9805ba3d 100644 --- a/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/LongIdTests.cs @@ -64,6 +64,42 @@ public void DifferentTypesAreUnequal() Assert.NotEqual((object)bar, (object)foo); } + [Fact] + public void CanParseString() + { + var value = 1L; + var foo = LongId.Parse(value.ToString()); + var bar = new LongId(value); + + Assert.Equal(bar, foo); + } + + [Fact] + public void ThrowWhenInvalidParseString() + { + Assert.Throws(() => LongId.Parse("")); + } + + [Fact] + public void CanFailTryParse() + { + var result = LongId.TryParse("", out _); + Assert.False(result); + } + + + [Fact] + public void CanTryParseSuccessfully() + { + var value = 2L; + var result = LongId.TryParse(value.ToString(), out LongId foo); + var bar = new LongId(value); + + Assert.True(result); + Assert.Equal(bar, foo); + } + + [Fact] public void CanSerializeToLong_WithNewtonsoftJsonProvider() { diff --git a/test/StronglyTypedIds.IntegrationTests/MassTransitNewIdTests.cs b/test/StronglyTypedIds.IntegrationTests/MassTransitNewIdTests.cs index e6dce6d74..98b0b4fab 100644 --- a/test/StronglyTypedIds.IntegrationTests/MassTransitNewIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/MassTransitNewIdTests.cs @@ -75,6 +75,41 @@ public void CantCreateEmptyGeneratedId1() Assert.NotEqual((object)bar, (object)foo); } + [Fact] + public void CanParseString() + { + var value = NewId.Next(); + var foo = NewIdId1.Parse(value.ToString()); + var bar = new NewIdId1(value); + + Assert.Equal(bar, foo); + } + + [Fact] + public void ThrowWhenInvalidParseString() + { + Assert.Throws(() => NewIdId1.Parse("invalid")); + } + + [Fact] + public void CanFailTryParse() + { + var result = NewIdId1.TryParse("invalid", out _); + Assert.False(result); + } + + + [Fact] + public void CanTryParseSuccessfully() + { + var value = NewId.Next(); + var result = NewIdId1.TryParse(value.ToString(), out NewIdId1 foo); + var bar = new NewIdId1(value); + + Assert.True(result); + Assert.Equal(bar, foo); + } + [Fact] public void CanSerializeToNewId_WithTypeConverter() { diff --git a/test/StronglyTypedIds.IntegrationTests/NullableStringIdTests.cs b/test/StronglyTypedIds.IntegrationTests/NullableStringIdTests.cs index 877d3e4d1..25c03edb1 100644 --- a/test/StronglyTypedIds.IntegrationTests/NullableStringIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/NullableStringIdTests.cs @@ -64,6 +64,27 @@ public void DifferentTypesAreUnequal() Assert.NotEqual((object)bar, (object)foo); } + [Fact] + public void CanParseSuccessfully() + { + var value = "123ABC"; + var foo = NullableStringId.Parse(value); + var bar = new NullableStringId(value); + + Assert.Equal(bar, foo); + } + + [Fact] + public void CanTryParseSuccessfully() + { + var value = "123ABC"; + var result = NullableStringId.TryParse(value, out NullableStringId foo); + var bar = new NullableStringId(value); + + Assert.True(result); + Assert.Equal(bar, foo); + } + [Fact] public void CanSerializeToString_WithNewtonsoftJsonProvider() { diff --git a/test/StronglyTypedIds.IntegrationTests/StringIdTests.cs b/test/StronglyTypedIds.IntegrationTests/StringIdTests.cs index 70508222c..e1a1a5a2a 100644 --- a/test/StronglyTypedIds.IntegrationTests/StringIdTests.cs +++ b/test/StronglyTypedIds.IntegrationTests/StringIdTests.cs @@ -70,6 +70,40 @@ public void DifferentTypesAreUnequal() Assert.NotEqual((object)bar, (object)foo); } + + [Fact] + public void CanParseSuccessfully() + { + var value = "123ABC"; + var foo = StringId.Parse(value); + var bar = new StringId(value); + + Assert.Equal(bar, foo); + } + + + [Fact] + public void CanTryParseSuccessfully() + { + var value = "123ABC"; + var result = StringId.TryParse(value, out StringId foo); + var bar = new StringId(value); + + Assert.True(result); + Assert.Equal(bar, foo); + } + + + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData(null!)] + public void CaTryParseFailOnInvalidStrings(string value) + { + var result = StringId.TryParse(value, out _); + Assert.False(result); + } + [Fact] public void CanSerializeToString_WithNewtonsoftJsonProvider() { diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=0.verified.txt index ded051483..31aeabf8a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,5 +35,17 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=2.verified.txt index cfd457a50..1e9420ebb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,5 +35,17 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=4.verified.txt index 2e42c1017..d42fd03f2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=6.verified.txt index 72e51cea4..5c4b4ee12 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Guid_implementations=6.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=0.verified.txt index 01078e1e2..37225a692 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,5 +34,17 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=2.verified.txt index 001600149..1517aa242 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,5 +34,17 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=4.verified.txt index a91fa169c..4c5564b13 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=6.verified.txt index 8efd32db9..9c6a97433 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=0.verified.txt index 443af91f8..d0a0d02b5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,5 +34,17 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=2.verified.txt index feece4e81..78a191a53 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,5 +34,17 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=4.verified.txt index 6cd836a22..f6cc284bf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=6.verified.txt index 02f88e910..ccafc7397 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt index b8a414ac3..5b151cc04 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,5 +35,20 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt index dd245d5bc..58fc98eaa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,5 +35,20 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt index 60c4a67fc..e4498eb8b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt index 00cde3b2a..f50fff4a4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=0.verified.txt index 264fdc2f7..ef0618d91 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=0.verified.txt @@ -43,5 +43,12 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=2.verified.txt index 145455f5e..b9ee1ee82 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=2.verified.txt @@ -43,5 +43,12 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=4.verified.txt index ae448f8ef..a3544a78b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=6.verified.txt index 83ea548a4..8ced36710 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=0.verified.txt index bb4463ea5..5fdc4133f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=0.verified.txt @@ -43,5 +43,17 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=2.verified.txt index 32930db22..bc2c45ccd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=2.verified.txt @@ -43,5 +43,17 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=4.verified.txt index 29abe8d09..c52add7f9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=6.verified.txt index 13bb9ceb0..46568181a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=0_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=0.verified.txt index 2bf42d5ad..fef819354 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=2.verified.txt index d8b30449a..9f7b88427 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=4.verified.txt index bbed26476..e536fbc49 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=6.verified.txt index af92743c9..470058245 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Guid_implementations=6.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=0.verified.txt index c1b350e6f..7f1dab04a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=2.verified.txt index 8c6792f30..6c992a597 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=2.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=4.verified.txt index 277aa3ccc..eda5ed24e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=6.verified.txt index dc34c1c7f..904223aaa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=0.verified.txt index c42e07b3b..bfd04227b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=2.verified.txt index d418d522e..3a6b9f5e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=4.verified.txt index b9ef467df..6da6d2af4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=6.verified.txt index 385158bf6..8fe246998 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt index 9ccc1a077..a8b5634fd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt index 75a4fb95e..990febbd3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt index acb51516c..689064177 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt index fa1903eef..fd38772f8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=0.verified.txt index b4b70539f..02d92dba9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=2.verified.txt index 5ca871ef4..9b903fd7d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=4.verified.txt index 9fb7f251c..11b1ca3a1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=6.verified.txt index 6e25a5203..e7731eed8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=0.verified.txt index bbf698715..473f9e28a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=2.verified.txt index e75dc4226..508130327 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=4.verified.txt index ff2965348..8f97cff6a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=6.verified.txt index 82f90e586..bda122965 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=10_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=0.verified.txt index 4eefd5207..26e15ee5b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=2.verified.txt index 148132f05..d86020a34 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=4.verified.txt index 92bb4caa7..577a46798 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=6.verified.txt index 3995eae63..f92cae80f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=0.verified.txt index d43c7301f..894200c97 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=2.verified.txt index e119ee009..23ac58498 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=4.verified.txt index e7852f74f..1405ecabe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=6.verified.txt index b092c74ed..0d38ce4b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=0.verified.txt index 42bd37de6..406b32a75 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=2.verified.txt index 309a1777f..c2fc76763 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=4.verified.txt index c2f752338..88d1947c0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=6.verified.txt index 1bcdf7ddc..81757ed2b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt index fa53b6cd0..fc0a6afaf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt index 4b92b7132..3d9f28a2e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt index 232036eea..b51d0cd3b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt index 857e850db..027951d1a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=0.verified.txt index c45fd7823..0c67c113e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=2.verified.txt index aa794a4a2..38bc312ab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=4.verified.txt index a60263f9b..2b8d28eeb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=6.verified.txt index beea672e6..51417b2be 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=0.verified.txt index b28250385..f500f9ea4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=2.verified.txt index 79a347cf6..59711b025 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=4.verified.txt index b319e6fcb..88d89ef88 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=6.verified.txt index b2236a000..2629af176 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=12_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=0.verified.txt index 1f82278dc..88e6b9ef1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=2.verified.txt index 426401906..cc965c790 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=4.verified.txt index bfd941dfe..61e6c5902 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=4.verified.txt @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=6.verified.txt index 898a5c344..92278324e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=0.verified.txt index c80cdfa0c..454029ee7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=2.verified.txt index eb861f8bf..48c632d2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=4.verified.txt index 63aa24cad..3a1bce0aa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=6.verified.txt index 1e7000a8f..1a3ca4ebc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=0.verified.txt index 12e9002fe..ebb4e6971 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=2.verified.txt index 41d2052e9..43cddc269 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=4.verified.txt index dcb4adbe1..2c6170379 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=6.verified.txt index 81b89c6c2..fa46cc274 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt index 501e086d0..0ea64fe03 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt index b21c8815f..04f6bc6b8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt index 5551d1f35..9f7494263 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt index db7915791..19f092cbd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=0.verified.txt index abda67e9b..a5f54fce4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=0.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=2.verified.txt index bcd7083fb..dd2d40ea5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=2.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=4.verified.txt index 905b027e7..4aeec11ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=4.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=6.verified.txt index c7d69304f..0a4fcdcd1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=NullableString_implementations=6.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=0.verified.txt index 9feea5d6b..670fcc21e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=0.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=2.verified.txt index 241f46871..7c6f362d7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=2.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=4.verified.txt index c8deaad6d..35a926891 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=4.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=6.verified.txt index 19863137e..49588edd7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=14_backingType=String_implementations=6.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=0.verified.txt index 194e7542b..bd7f3e39b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=0.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=2.verified.txt index 6e1dbb941..1e9970720 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=2.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=4.verified.txt index 292c2428f..a44839773 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=6.verified.txt index b055114b5..1c3ea4092 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=0.verified.txt index 04d8d094c..dd29925f2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=0.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=2.verified.txt index cd56bfdb8..5c8f2aefc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=4.verified.txt index 82c961fea..071501ab7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=4.verified.txt @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=6.verified.txt index 7c1beae5a..f9d80e3f2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=0.verified.txt index 241ac4315..ee3b8a651 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=0.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=2.verified.txt index 86a343456..bad52eee3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=4.verified.txt index e6dfea3e5..dd0c429b2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=6.verified.txt index b8576cdcc..c4b2c1b65 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt index 758367b61..c5528d4e5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt index 0673ce60f..677cedb76 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt index 85bd3ec3d..9ac5c9ee2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt index b11f79dea..d254a809b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=0.verified.txt index cd19a31a5..45a74533e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=2.verified.txt index 7c9a767a0..6fa439e6d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=4.verified.txt index 87cbee9c2..898914f00 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=6.verified.txt index 7510b4d3d..75d9e40ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=0.verified.txt index c865b44d0..2261f879c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=2.verified.txt index 65a4aa17e..424f846c8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=4.verified.txt index 83e0800bb..006ce5a32 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=6.verified.txt index 611e2f1a0..7fe220de0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=16_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=0.verified.txt index 211608ccc..994021846 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=2.verified.txt index 0e5d5ab0d..d54f11e5e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=2.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=4.verified.txt index dd03a2d8d..bdb7473c5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=6.verified.txt index 50a48d3d2..cf9c28d42 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=0.verified.txt index 4685ac834..6308c322c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=2.verified.txt index d4a4846ab..014d53572 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=4.verified.txt index 19f743ef4..35be620d4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=6.verified.txt index 000b4ffbb..079cdc0bf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=0.verified.txt index 0e9376897..9c462b91f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=0.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=2.verified.txt index 10bbe32e4..7101ae0e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=4.verified.txt index 9fc37bec1..5d2378f4b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=6.verified.txt index c4e157038..4553c57aa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt index 558ea0ffe..9aa2483f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt index 7df9e464f..80f5a9bf4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt index dfadb3d16..95a32f95d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt index 36d3683be..0b6e37b86 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=0.verified.txt index ee09c9a5d..e27f2fde8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=2.verified.txt index 24d920b0e..81dd0af66 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=4.verified.txt index 144a9fccb..ab8b8f76a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=6.verified.txt index 1dd57b895..856d6f984 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=0.verified.txt index d64e61fd8..af7ee5c01 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=2.verified.txt index 8d0620e90..3e79a54f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=4.verified.txt index 7bf9fde9e..0e57267b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=6.verified.txt index a26c69961..961dae567 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=18_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=0.verified.txt index 79c08cb83..1443a3afb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=0.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=2.verified.txt index 7007349de..b9d37fd1e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=4.verified.txt index ac02c972c..a7e741670 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=6.verified.txt index 44e4aeb43..612cf5c1e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=0.verified.txt index c538a6642..e6f02295b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=2.verified.txt index 2ce277d29..79ede42a0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=2.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=4.verified.txt index 0499f4904..3ec664bea 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=6.verified.txt index 785bbf7c8..23e3f672d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=0.verified.txt index 7f919ca6d..4e7cc1a09 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=0.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=2.verified.txt index 67c43f9e7..619432f22 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=4.verified.txt index d3cb95dff..c663f5bee 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=6.verified.txt index bc81e6e5a..9fd7ae862 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt index 3619bf2d5..1c8528d35 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt index 5f10d318b..39be2fba2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt index a8dee47eb..f922a7b4d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt index 43e9a4e8a..38db7cb25 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=0.verified.txt index d9eb8d0a1..774eaa69a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=2.verified.txt index 6424a8fea..f2bd67cba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=4.verified.txt index 6832a8adf..623d0c852 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=6.verified.txt index 6523bb1db..c895becaf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=0.verified.txt index 2c6b3d88e..e65a1082e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=2.verified.txt index cad2e406e..0817e9d6e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=4.verified.txt index 02a4a2d9d..8c1fe97a1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=6.verified.txt index b074e16cf..95ab9ac54 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=20_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=0.verified.txt index 0de87fb62..38b64b0d1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=2.verified.txt index 377decb04..04d098f42 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=4.verified.txt index 21d487148..e7bd16586 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=6.verified.txt index 039a56446..bf6c4768f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=0.verified.txt index 154e322c8..43696c386 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=2.verified.txt index aec1376ca..3589c24c2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=4.verified.txt index 2d025e868..93ee73bcc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=6.verified.txt index d66ad02a2..f360c0602 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=0.verified.txt index f630b8fdc..ee7321cfd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=2.verified.txt index 63b322c4d..d3a201210 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=4.verified.txt index 27d7fab62..e812d26c1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=6.verified.txt index 6c60c9a4e..93693b927 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt index ec8b7cd4f..cbcbc25ad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt index 830bb22b7..1dff62626 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt index 02c401197..f40e0bd7b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt index df25597b6..ae15559d1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=0.verified.txt index f4dfc74d6..b61235d4a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=2.verified.txt index c934c7960..2e644a7a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=4.verified.txt index 054466ea1..b26de7f05 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=6.verified.txt index e30a76f8f..ace48d18f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=0.verified.txt index e90a11773..2dc8e4187 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=2.verified.txt index 6308517d0..8e2ad7965 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=4.verified.txt index 59c1f6839..10273d86f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=6.verified.txt index 13ed9ed6a..1aeb1c233 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=22_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=0.verified.txt index cec9f93ef..d397ef02a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=2.verified.txt index 3c7808a44..aaab0fff3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=4.verified.txt index d6a13365a..2859a159b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=4.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=6.verified.txt index aa05d4ee7..232fc7c70 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=0.verified.txt index 6fb2cde57..fad78e727 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=2.verified.txt index 1bf5a3d86..aad5df8ec 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=4.verified.txt index 5e387eb65..be9436d74 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=6.verified.txt index 12c450152..78090035e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=0.verified.txt index 7c468580a..40766e37b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=2.verified.txt index 9d632a09b..857018b26 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=4.verified.txt index e266a957e..b9779abb9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=6.verified.txt index bc610e4fb..ca26ba12b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt index f2b4441e2..a42946320 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt index c241f14ef..a307304da 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt index 98cb6deb5..95f4ef398 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt index ce1144981..6ac4a3d07 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=0.verified.txt index f8bcc21c3..012defcd2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=2.verified.txt index 83c698b4f..7f9f0de73 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=4.verified.txt index b1c930f1f..66663a629 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=6.verified.txt index 8eb51b9f0..8821302d2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=0.verified.txt index 3174e434b..6d64e2766 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=2.verified.txt index 54d3c397f..40f54319c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=4.verified.txt index 5e44875b5..3f6494f65 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=6.verified.txt index 1730775cd..4f50ae94f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=24_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=0.verified.txt index 34a3d770d..92da451c8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=2.verified.txt index d40ed90d0..9ee5513d9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=4.verified.txt index 0ccde754e..20e64e202 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=6.verified.txt index 02b6e655d..50d230408 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=0.verified.txt index 232ec5018..4f3707998 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=2.verified.txt index bdd55ec7f..971572710 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=4.verified.txt index d7f636f5a..f02fc9f03 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=6.verified.txt index d168f1af4..775424e7a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=0.verified.txt index 8a67cb348..32a68cdf3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=2.verified.txt index f8ca379d4..8ecb74385 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=4.verified.txt index 797793d45..423997f83 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=6.verified.txt index 2f5cc78e7..3b5c6224f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt index cdd3bd0cf..d0f5d941d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt index aad9946ec..7b4c1a1fc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt index cb9c6d68d..c82722ab2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt index 363048b20..d8f9aac63 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=0.verified.txt index 07e4af198..f126ffd5a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=2.verified.txt index aa48d7a9e..c1dd1b34c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=4.verified.txt index a9ce63d5e..d3099998d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=6.verified.txt index 74c5eb2da..4ba4885a7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=0.verified.txt index 7e24664a0..139146501 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=2.verified.txt index 74c0e5d0c..d4f564c0e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=4.verified.txt index ecc4e3fbc..4ff0febed 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=6.verified.txt index fb17c9a8e..0fc8e0c4b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=26_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=0.verified.txt index 0ff6594db..8345712a3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=2.verified.txt index c97e7fbea..248e4acdb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=4.verified.txt index c17d1f458..15ecb1e73 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=6.verified.txt index c26af6cd9..af6914e66 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=0.verified.txt index 8e590dc5e..f83cf4dd2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=2.verified.txt index 7822d351d..c642cce59 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=4.verified.txt index 7dedd98b2..043be175c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=6.verified.txt index ae9e502f9..6461ec5aa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=0.verified.txt index 30f88d9e3..010bbe5f0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=2.verified.txt index 847ee0353..b3db43f18 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=4.verified.txt index 15adbe86f..653163e55 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=6.verified.txt index e6b03e1a8..f7f04613f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt index ea1250d30..6615afec0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt index 858ffceac..6c25e4143 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt index 04372c41f..818950c48 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt index 36ded100a..4cf59012a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=0.verified.txt index 8e0dd96c9..974ba50f3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=2.verified.txt index c05ebcbbb..3eae1d111 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=4.verified.txt index 0ad8d75b7..787c7c8e6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=6.verified.txt index 5dcb6cb87..58bf68814 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=0.verified.txt index fa7ea405a..f7bac9def 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=2.verified.txt index 0f1130282..b3a475e09 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=4.verified.txt index 63e4e2c42..e951255d4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=6.verified.txt index 01b32f768..6865411be 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=28_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=0.verified.txt index f96742984..d4c5debbd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=2.verified.txt index f10c0b910..b9552685d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=4.verified.txt index 9bdc1063c..3084eaa89 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=6.verified.txt index 81e607f2f..3d1d4baa5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=0.verified.txt index b5ff3a363..c279e5ebb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=2.verified.txt index d50afed34..b5845245f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=4.verified.txt index c2b70fe83..3a7926c87 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=6.verified.txt index 03191e9a6..77080c44d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=0.verified.txt index ab00e61d2..264bd1444 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=2.verified.txt index 0b58ab5ad..cb3a59839 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=4.verified.txt index f481ef25c..6500c30fb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=6.verified.txt index bd67cce1f..532d4aad4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt index f54b99326..f8f5b2480 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt index 7f8ddbf08..8fcfdf492 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt index da80cd0f6..65e1b2030 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt index 0c1267c3d..496e2e6ee 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=0.verified.txt index 9440f3fb6..12617265b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=2.verified.txt index f2c45275e..aa19bfcc8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=4.verified.txt index c95c0c2ff..e0159ee75 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=6.verified.txt index e7b5d490b..610a22a42 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=0.verified.txt index d86737ff9..59f220ce6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=2.verified.txt index ab0861779..e515d9844 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=4.verified.txt index e2a5e2e01..b08faffe9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=6.verified.txt index 29a521353..4430cc826 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=2_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=0.verified.txt index 188de8470..3691ce3ee 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=2.verified.txt index 8b109d9ff..6fa6ed056 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=4.verified.txt index d90c01911..e718cd35e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=4.verified.txt @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=6.verified.txt index 9594e104d..874436632 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Guid_implementations=6.verified.txt @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=0.verified.txt index 3bc5c3215..e564cd236 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=0.verified.txt @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=2.verified.txt index b968b9847..76dfdc5a7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=4.verified.txt index 19f277cfb..0e6608e38 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=6.verified.txt index 0f4c59fed..23b2e59b3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=0.verified.txt index fd0e852d8..b9b823ea5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=2.verified.txt index f13ee5ce6..2e8f8253d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=4.verified.txt index 139126777..68bf3a537 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=6.verified.txt index 2d4cefe80..ba6659f62 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt index d861b6f59..e274d1d2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt index 89da3d93a..71f9f1cf9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt index cf94ed434..da601cf37 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt index 67863e67e..c97d57405 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=0.verified.txt index beb3a7c2d..19a4d1db6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=0.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=2.verified.txt index de3d8b270..77945725f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=2.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=4.verified.txt index 905034d0f..1b3d1c96a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=4.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=6.verified.txt index f48f076e1..e9ad5bac6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=NullableString_implementations=6.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=0.verified.txt index dac01f2e2..d17a94f03 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=0.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=2.verified.txt index ec034609d..bb2f7abbd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=2.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=4.verified.txt index 4a4c93d37..52571c3b0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=4.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=6.verified.txt index 545faaac3..2a234d199 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=30_backingType=String_implementations=6.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=0.verified.txt index 9f9cd1bc8..89f82836e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=2.verified.txt index 519411f77..56f15b865 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=4.verified.txt index d71300c48..b71126a31 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=6.verified.txt index 404e39ab6..78607bc05 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=0.verified.txt index beed07d3d..829685133 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=0.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=2.verified.txt index c50d96e26..ed9e2001a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=4.verified.txt index 0872c8438..4e08b44c1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=6.verified.txt index 0587acd0e..4ada13501 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=0.verified.txt index 0e1b6e702..2fdc103fd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=2.verified.txt index f9c6850b5..362a31967 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=4.verified.txt index c18592a03..77a84d2c1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=6.verified.txt index 1b0793adf..c4ebee1d6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt index 29b647e26..e6b2d5533 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt index e4b47961f..2c07bdf6f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt index 6e62e41cf..aaa983753 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt index a38ed5e95..3b5684d70 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=0.verified.txt index 1eb93be65..e2b26e63c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=2.verified.txt index 8385e0397..cc3481581 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=4.verified.txt index 85a24e621..66729bfb0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=6.verified.txt index d465a5f19..9b50cf0e8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=0.verified.txt index 7d7a27964..60c051afe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=2.verified.txt index be0db1ea0..41e0c7a68 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=4.verified.txt index 9d655e1f7..9b782af7b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=6.verified.txt index 4d13c98e2..ae2ca482d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=32_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=0.verified.txt index c8da0cca5..ec58a198d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=2.verified.txt index 656968dd8..4a67a926b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=2.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=4.verified.txt index 4fcf4e514..cc5abfc11 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=6.verified.txt index 4aafeb6ac..2374c4317 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=0.verified.txt index f1eb65971..4a7c1c96b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=2.verified.txt index dfcb61df7..e9b84b6c2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=4.verified.txt index 3f81dd3a9..e8dccb1cd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=6.verified.txt index 0020fc840..54121cf2e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=0.verified.txt index aeeee4deb..8f01b85f2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=2.verified.txt index ede203228..78f3769da 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=4.verified.txt index b17ce18ad..4acc8eeef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=6.verified.txt index 2cce165a4..d7c0cb465 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=Long_implementations=6.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt index 914c4e70f..c0753bd73 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt index f1072ceed..88a432c7e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt index 924cc3ab9..7a33582ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt index 46af76e07..a99df6368 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=0.verified.txt index 26b4195b0..898c0a6b0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=2.verified.txt index 28359c1b5..f4fa76c0b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=4.verified.txt index f92342b54..a5f0181d8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=6.verified.txt index bf18b449e..1537aa432 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=0.verified.txt index 9ab95fc64..516f8770f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=2.verified.txt index 3ae3f7117..e3198c9c3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=4.verified.txt index 95fbf4b1e..4804a46fa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=6.verified.txt index c91b23b2d..713439bfa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=34_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=0.verified.txt index 6044ce9b2..caa188f3e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=2.verified.txt index 43028c737..aa43f8cef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=4.verified.txt index 52237a728..5f18b05ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=6.verified.txt index 0cad40924..e255010c6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=0.verified.txt index f1e3a7db8..9ebf661ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=2.verified.txt index c55ef355f..7259da9be 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=4.verified.txt index 5ba5b94aa..fa16f6d2c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=6.verified.txt index 06e74df24..011fbbe97 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=0.verified.txt index 774bc9ad6..f002f0f70 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=2.verified.txt index e79ca31b3..958657786 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=4.verified.txt index b39e93ca4..bf370d6a0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=6.verified.txt index 7b5369b83..84c889095 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt index 70a50b488..c234b4e65 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt index e3b9625d0..89f8db2c3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt index 697b97bc7..0697e1d6d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt index 2d9db09ed..dca891d73 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=0.verified.txt index acf6f08cf..dcb191839 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=2.verified.txt index 318e2b14b..e7f81c23a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=4.verified.txt index 7d6922ee0..0b9653fbe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=6.verified.txt index fd54b4c06..5c3a46199 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=0.verified.txt index f8ab6f54f..a8a3065e2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=2.verified.txt index 8a3a33c98..cb8cbcc50 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=4.verified.txt index 7d1e2f7d6..c777949f6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=6.verified.txt index 6cd0beee6..74a7f51b6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=36_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=0.verified.txt index 7d5a197cb..54a7b0c2d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=0.verified.txt @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=2.verified.txt index be6cf8c81..734d99cce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=4.verified.txt index 995713dc9..6d2638424 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=6.verified.txt index a7c3e9e96..b81d73fc9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=0.verified.txt index e3cf254a2..f6e55c60b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=2.verified.txt index 93ebd3e8a..1bccf78e6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=4.verified.txt index dc463682e..b519ad39a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=6.verified.txt index 1400cc34a..a6ca764b1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Int_implementations=6.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=0.verified.txt index 4c928b6c0..1b0e1460e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=2.verified.txt index f80c8c2ec..0afccf340 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=4.verified.txt index 7cf8fb223..16d766223 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=6.verified.txt index 65512f35a..f72bb7106 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt index e077bd5f0..50447d4cd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt index bd8e34bac..c2a83901b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt index 547de227e..fcdd097ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt index fc4852b8f..f255d3c57 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=0.verified.txt index 566cba66f..7a23334f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=2.verified.txt index 0f70be81d..7ae8d607d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=4.verified.txt index 8556bf757..0dc4a9c77 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=6.verified.txt index a03dc6318..7848533b7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=0.verified.txt index 6930d2358..d35f24082 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=2.verified.txt index 52b8ed272..64edeb955 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=4.verified.txt index 194f60a70..839b47dfd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=6.verified.txt index dfe334f7c..81305d5da 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=38_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=0.verified.txt index dadc7e04f..de49aeaaf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=2.verified.txt index e54e08ddc..64fa969b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=4.verified.txt index a358b242a..9aaa995c8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=6.verified.txt index 86c52e5cd..3787af530 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=0.verified.txt index 0808e5ba3..963c03ca1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=2.verified.txt index 073dcb398..a43db9e79 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=2.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=4.verified.txt index 2e1c44421..ec9b8ea99 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=6.verified.txt index 6686f9ba2..bd325e637 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=0.verified.txt index b41a8f2af..f3705909e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=2.verified.txt index d7cf84a5b..26a56865c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=4.verified.txt index dc5a97e5b..fc4d8228b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=4.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=6.verified.txt index e6011d8f7..a80b39cf5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt index 85fddd42d..ec4a763bc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt index 5f9c3f7b5..095b62045 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt index 337983286..9764f46b2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt index e800f088b..11c1e032d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=0.verified.txt index b99035787..3a1ad6b49 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=2.verified.txt index eeceb66ed..1b097f42e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=4.verified.txt index 871acc1a5..43b087441 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=6.verified.txt index f3d901092..6b5e503c3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=0.verified.txt index b8d70ecfc..d2860ed40 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=2.verified.txt index 0fe4d52d8..d629f2b5b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=4.verified.txt index 3cfc89fb8..c162244b5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=6.verified.txt index 54f71df08..b74ce8de7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=40_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=0.verified.txt index fa03935df..4b8f258ad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=2.verified.txt index c899ebcbf..04fba9056 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=4.verified.txt index d46203db0..1ea492fab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=6.verified.txt index 7a193d986..0f7c293e4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=0.verified.txt index 9e43d35df..0d15e6d60 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=2.verified.txt index a29760e38..68010e364 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=4.verified.txt index e9dd27dbc..2f0285aef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=6.verified.txt index 6b774e67c..b25c074ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=0.verified.txt index 11aef7b1f..7a660917c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=2.verified.txt index ec6d91e03..905e7c37d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=4.verified.txt index b6619ba8d..85530b64d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=6.verified.txt index 11e7d78ce..b6d49a4ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt index 5ae3bc5db..aa13ae9b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt index 595c53088..367bf002b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt index 096e60ede..b28e35d9c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt index a0bada376..258f4ff70 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=0.verified.txt index a4fe24c28..b6bec22ea 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=2.verified.txt index faf7e3e97..740e9095a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=4.verified.txt index f2c090a11..fc3a4f7c4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=6.verified.txt index d96f03e9c..8f229ccf1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=0.verified.txt index baf3f8544..0cd138ae1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=2.verified.txt index 91e77e956..577d8357c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=4.verified.txt index b3e3cae0e..cdca8b767 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=6.verified.txt index ab8a6cf5f..80509b358 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=42_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=0.verified.txt index 8de8f4377..82ff458b8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=2.verified.txt index 4ae2fc8d7..52ebfd8ee 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=4.verified.txt index 5d665aa9e..fae084e40 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=4.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=6.verified.txt index 3d122dfc2..b91f0a931 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Guid_implementations=6.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=0.verified.txt index e5b65e623..99c6b5a8e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=0.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=2.verified.txt index 9ce227afb..4665fe602 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=4.verified.txt index d6edb7330..8d92e4be2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=6.verified.txt index 14d01ca84..5165c8e67 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=0.verified.txt index ae92f9800..165b2abd7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=2.verified.txt index 23853b853..c222d7d81 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=4.verified.txt index 390f2c1a1..1f53d8d0b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=6.verified.txt index e94594b5c..7ba4059e6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=Long_implementations=6.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt index 256b6f654..ed68b949e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt index b2950aedf..26224ca88 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt index 93ecd69c8..9b4b7f180 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt index 13952cfe2..ba3fb769f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=0.verified.txt index 17b696f85..06b2614c7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=2.verified.txt index 462dff9f1..65bdaf934 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=4.verified.txt index 2b07fae6a..523df0791 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=6.verified.txt index 95aca8dab..eb7994634 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=0.verified.txt index 7942462cd..94cf634f6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=2.verified.txt index 1a2375126..76f90f5ca 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=4.verified.txt index 385acb512..c943f3363 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=6.verified.txt index 54c3004f5..799e79af5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=44_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=0.verified.txt index d7fafeba4..9f9653e2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=2.verified.txt index 8fb1d756c..d89a6d962 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=4.verified.txt index a07bd183c..f15fa8f81 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=6.verified.txt index 5723e1d21..32a90c185 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=0.verified.txt index e98f64273..2e36396f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=2.verified.txt index 85fe8af43..b9a78f8f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=4.verified.txt index 0b0763162..b3a0f0c68 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=6.verified.txt index 1667fda86..43c4e1f38 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=0.verified.txt index a0a146757..75123ae03 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=2.verified.txt index 0fe70b4bd..f57e0aaeb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=4.verified.txt index aaeb240bf..95456124c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=6.verified.txt index c083c3782..ef8d43efa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt index 96360a7a4..0f5251f7f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt index b23837d53..1f3625bc5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt index e55aff557..ec4e72f45 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt index adecbd530..864e3a114 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=0.verified.txt index 6d593f904..f3987cbcc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=0.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=2.verified.txt index 32443f689..60ba3c798 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=2.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=4.verified.txt index 0a5bf11db..e58c326ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=4.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=6.verified.txt index 8c62458c4..8a9c2c77c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=NullableString_implementations=6.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=0.verified.txt index 942401e80..28977f0ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=0.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=2.verified.txt index de9f65837..5b88a8e1a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=2.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=4.verified.txt index 4c36d2d55..74116f047 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=4.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=6.verified.txt index cc4a18460..8157068dd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=46_backingType=String_implementations=6.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=0.verified.txt index 03dbb3c9f..aad0f315e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=0.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=2.verified.txt index 92da89a22..65f92a02f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=4.verified.txt index c40b04700..6525a25df 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=4.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=6.verified.txt index c093fdb66..41cbf06bc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=0.verified.txt index 4b822535a..a078faf6a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=2.verified.txt index aaf95ace8..53775ed33 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=4.verified.txt index 19056a123..bbb8d753a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=4.verified.txt @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=6.verified.txt index 4cd595320..d59303800 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=0.verified.txt index 70fe9a37c..c02346f1d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=2.verified.txt index f956875e8..1d04e4452 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=4.verified.txt index 369e4c9be..44d14cfdd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=4.verified.txt @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=6.verified.txt index 50e22ebed..3d02ab547 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt index 336f15716..0a63d170e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt index f4f2a657b..5658dcb7f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt index 70d5ba474..be074a0e8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt index 7f105bfba..0b30d4657 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=0.verified.txt index 8248ff194..7e60155cb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=2.verified.txt index 24f27c1e7..84bd95584 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=4.verified.txt index cbb8f39ca..cf29714f6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=6.verified.txt index b95134b0c..fd8f24086 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=0.verified.txt index 77433704b..19b0f9485 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=2.verified.txt index ab8f71a3f..c18c30857 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=4.verified.txt index e02260802..6f54e5722 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=6.verified.txt index 891fbeaec..ac61f96b8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=48_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=0.verified.txt index bdabfcb00..d179806f6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=2.verified.txt index e3df153df..4c93676fc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=4.verified.txt index 432df2cb6..295238640 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=6.verified.txt index 5216394e8..1dff441f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=0.verified.txt index 8336c445d..a966b25d1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=2.verified.txt index 0e4d91d16..0959e4fc1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=4.verified.txt index e5023ea7f..ff36b6f63 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=6.verified.txt index 29c947e58..58e444cad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=0.verified.txt index 87729380e..d95957529 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=2.verified.txt index bde6ecb0f..096baa947 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=4.verified.txt index c6320b0d2..82b891f45 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=6.verified.txt index ea1ca0542..2c77062cd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt index a252f2370..4f24da8b0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt index bbb3b98b0..c55f588ed 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt index 20f0e6048..e725c7772 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt index 45b282d54..9852e772a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=0.verified.txt index c6622d378..54a0ebc37 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=2.verified.txt index 935d3e757..99564b53b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=4.verified.txt index 9ec76def6..c1c2fd8ca 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=6.verified.txt index 5b9ef99e2..cae1137ae 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=0.verified.txt index 5d18f5475..f62bc8947 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=2.verified.txt index f54921703..88267055a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=4.verified.txt index c45a38488..934a6af2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=6.verified.txt index c6ca5ae3d..fbc63dfc7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=4_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=0.verified.txt index 74b3f985d..c59a6d866 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=2.verified.txt index bef56bd9d..2aee3ad4a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=4.verified.txt index 14f823999..62a24d6c4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=6.verified.txt index 02cc61e70..8a23c3cab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=0.verified.txt index 830548f68..78cc26ca0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=2.verified.txt index 201c1d3a5..10b29f5e5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=4.verified.txt index 1e9fc8a8e..9fd6ca832 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=6.verified.txt index af7322448..24d96f47b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Int_implementations=6.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=0.verified.txt index c29cede8f..8619d7f10 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=2.verified.txt index d1c68d776..024ced44c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=4.verified.txt index 52391548d..c09493840 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=6.verified.txt index 9aa13e282..e66bf1979 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt index 0d1fba458..71ff3eb60 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt index 0e1cae33f..2ce568cfb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt index 818c194cf..d4d2bc693 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt index cac4b853b..de467b400 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=0.verified.txt index c027a4749..109237bf7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=2.verified.txt index 6cdc4d3ee..9449421c8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=4.verified.txt index b01a8c1dd..8e5798b49 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=6.verified.txt index 62c37e72b..93c1fa84b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=0.verified.txt index 5fc1f9594..bc5840535 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=2.verified.txt index 01be5111c..79ce12048 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=4.verified.txt index 8bf382a6e..91c3dce42 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=6.verified.txt index a894b70f3..60419e07d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=50_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=0.verified.txt index 14287be4d..6cd038223 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=2.verified.txt index b5725c055..60cfec1c7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=4.verified.txt index a805f7b7b..78d1fbaa1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=6.verified.txt index ede5c8b7f..591d98bb1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=0.verified.txt index 4f180eb82..3985d59a4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=2.verified.txt index 4888525b3..058de8a0d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=2.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=4.verified.txt index 8a3a54609..ca3c389e8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=6.verified.txt index 130096ed3..c155ebf57 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Int_implementations=6.verified.txt @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=0.verified.txt index f339a4a25..155aeb405 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=2.verified.txt index 1cb5fdb93..8e667ce58 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=4.verified.txt index 41c24879b..c34520fe1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=6.verified.txt index 287d01cde..ce79a142c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt index f7a8e23cd..226f4ecce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt index 86a53cf55..a7d3c629a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt index c61abce79..09c532f4b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt index 4f41223fb..81e9e1869 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=0.verified.txt index 6555aa2f9..e894d7ec0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=2.verified.txt index b80e03e21..29317181b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=4.verified.txt index 4206df591..47a6c961e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=6.verified.txt index 181c3b15a..b16e5b1cb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=0.verified.txt index 56e25435d..f6f6c50ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=2.verified.txt index 986b3045a..1827211cd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=4.verified.txt index 5a5cd701f..33f112dd4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=6.verified.txt index 4962a475d..6a2beb474 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=52_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=0.verified.txt index a80d8ce2a..687e3adb8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=2.verified.txt index 6be81c54d..4830d99dc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=4.verified.txt index c678364fd..458d0e36d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=6.verified.txt index 5acb780e5..1ea84b6e3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=0.verified.txt index 52d17d86e..42cd73728 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=2.verified.txt index 1e4487da4..be8f6fa8e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=4.verified.txt index bf3455804..d29eb5795 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=6.verified.txt index 61f9826c6..e7b5e3d41 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=0.verified.txt index 42bfe9f6c..1b3c7d3c5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=0.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=2.verified.txt index d6c26948e..b4350bc5c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=4.verified.txt index 069545233..26cea613e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=6.verified.txt index d9578fa9d..e36f38b44 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt index 0f89b2821..1565b78f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt index 6735b3667..10a2123af 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt index 71d3a0c12..bfe06b517 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt index 82a03b7d8..c97a3f96f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=0.verified.txt index 8cfd09416..526b37cca 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=2.verified.txt index d7be8d5da..b46451b3b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=4.verified.txt index c5e9b83c9..de941fd8f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=6.verified.txt index 2acb62174..9c71190c1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=0.verified.txt index 01c1122ee..337e13e79 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=2.verified.txt index 62f85ae44..d69195711 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=4.verified.txt index d698664b8..7db3d832a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=6.verified.txt index 6d25c57ff..219ab3929 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=54_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=0.verified.txt index 6e06a9bce..d9d4a1e09 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=2.verified.txt index 6525ea8b1..b8f1e265d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=4.verified.txt index 667ef258f..9550b078e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=6.verified.txt index 94f17d951..2128ec935 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=0.verified.txt index 09eeb88eb..113f57253 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=2.verified.txt index 39051df41..d243dac97 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=4.verified.txt index c7947cce6..2ce5b06d3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=6.verified.txt index cdcd225d3..5fdba4871 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=0.verified.txt index 8ed2eaf78..3992658ac 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=2.verified.txt index f6c88de02..949d56c91 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=4.verified.txt index 29253a73a..326acfac9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=6.verified.txt index 2780b7afa..8e89d57a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt index 655f48637..7aea07d61 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt index 986efc943..b1ea23baa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt index 4b59df937..b8e3cac6d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt index 0be13c753..d43d2d0cf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=0.verified.txt index 04b5fb570..d216e7ff3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=2.verified.txt index 7076bf68d..fb1d91e21 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=4.verified.txt index b92c2ecda..bbf8fb1fe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=6.verified.txt index 647d8d712..c955ff15b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=0.verified.txt index 2fe8c5659..464ec521d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=2.verified.txt index 7891c1675..8b567bd21 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=4.verified.txt index cb347f774..5dbf288af 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=6.verified.txt index 326594bcc..65a825c1f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=56_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=0.verified.txt index 5c7a44b39..f1b38d2f5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=2.verified.txt index b1fc6fe23..0ead177b7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=2.verified.txt @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=4.verified.txt index 93fb7f31f..c6e271833 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=6.verified.txt index 2d15bbe19..bbbaed9b7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=0.verified.txt index 9f30e3c8a..bdbfff5e1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=2.verified.txt index 1e251ae8d..117df4b6c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=2.verified.txt @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=4.verified.txt index 90f3ae91b..7c0191ce8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=6.verified.txt index 9f70b1d05..e06859ddd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=0.verified.txt index e31445d23..b3f180794 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=2.verified.txt index 4e087c276..6040fa23b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=4.verified.txt index 5132b77e5..6146b51da 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=6.verified.txt index 9680ddd53..2ad576ef7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt index 189949803..ea8bc9442 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt index 6764ab601..accefb561 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt index 947c0076e..fa7fb568c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt index f486c0937..866f174b5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=0.verified.txt index dd85700e0..536ec55f7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=2.verified.txt index 3c4cc6854..f3728a355 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=4.verified.txt index f141b3c70..869c8c22f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=6.verified.txt index 5c5d71c25..eb12b2193 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=0.verified.txt index 9c83dc747..648815447 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=2.verified.txt index ea259a5f8..84e2f70d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=4.verified.txt index ecf8e8288..bab45d299 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=6.verified.txt index 5b34d6c77..b960f673a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=58_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=0.verified.txt index 3b7408bb7..632ac9a2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=2.verified.txt index 73c179774..3e9a68e35 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=4.verified.txt index cb93e2a05..3ce7dff0a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=6.verified.txt index 1f0ef8bd0..30a049744 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=0.verified.txt index bf50776b5..a8d514090 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=2.verified.txt index c4b276926..2afdbb6da 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=4.verified.txt index 9bb9dc032..ed9b94e6a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=6.verified.txt index 874fde737..a97e53e78 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Int_implementations=6.verified.txt @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=0.verified.txt index 4a1be347a..6957b4552 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=2.verified.txt index bb4e5ceda..992995324 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=4.verified.txt index ff82b6f98..7a50381d3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=6.verified.txt index 66cbcd9ab..9b4e446ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt index 8482e009e..d7b226f22 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt index 8faea53c6..d5a5592b4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt index 1846da66c..1d8794ee3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt index 0d4a51ab7..83bb55aab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=0.verified.txt index ab24e0b8d..fcdabc47b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=2.verified.txt index c09768189..821abed1f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=4.verified.txt index 92e787cf1..698b65f38 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=6.verified.txt index 13a01dbbb..e33ef06cf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=0.verified.txt index 7ed3c3afb..c213aa015 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=2.verified.txt index edc60a11d..844053b2c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=4.verified.txt index fec38441f..59bdf18bc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=6.verified.txt index 3bba93795..775523b5f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=60_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=0.verified.txt index 51a3cbe77..69e3dddf1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=2.verified.txt index 1e4936444..09190aab6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=4.verified.txt index 2df62346d..f3856e753 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=6.verified.txt index 69224101c..184d9e386 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=0.verified.txt index a2f7eed1b..752beda51 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=2.verified.txt index 9e659a8c6..fb9a77825 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=4.verified.txt index 9c5c16f05..cd1745db7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=6.verified.txt index 8eac88355..9274f78de 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=0.verified.txt index 262c67704..7b4d3a34b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=2.verified.txt index 6a7062db6..56d3df871 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=4.verified.txt index c89552402..0033d8f8e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=6.verified.txt index 888756220..f8790bb87 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt index e923a9c3c..19ef5b20f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt index 7a754905d..2d4bb6acd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt @@ -39,6 +39,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt index 1ecc81e2c..cc8281900 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt index 00f8d284d..dad3a3f6b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=0.verified.txt index edb901ce8..61a38fbd3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=0.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=2.verified.txt index e7664b41f..a6044e268 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=2.verified.txt @@ -47,6 +47,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=4.verified.txt index 41bd12b3d..ffe531143 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=4.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=6.verified.txt index bc3abbfbf..1cc27d3b4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=NullableString_implementations=6.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=0.verified.txt index a224a9212..77cd1069d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=0.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=2.verified.txt index cdffd2cbc..0af47dd4c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=2.verified.txt @@ -47,6 +47,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=4.verified.txt index 2710c4c57..fbb4f1a76 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=4.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=6.verified.txt index 8421957be..d611252fe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=62_backingType=String_implementations=6.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=0.verified.txt index f55856033..70dbcec20 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=2.verified.txt index 04f9df4c7..ca104425c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -38,6 +38,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=4.verified.txt index c16ae72ee..c0268081f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=6.verified.txt index 7d1cfe063..dc4156478 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=0.verified.txt index 748ab235d..3982f250f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=2.verified.txt index fadf05993..6b9819f10 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=4.verified.txt index 1138086f0..5cd5e8f0d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=6.verified.txt index 30b1f4762..7d3847a18 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=0.verified.txt index 7713c648c..bdd91a10f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=2.verified.txt index fdf111468..d66656019 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=4.verified.txt index c69de278f..68003388d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=6.verified.txt index 875ddedda..86d8fa0df 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt index ec3e83d4a..9415fbffe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt index 900cd76f7..4b5ce0ffa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt @@ -38,6 +38,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt index 5e7af2205..dcee59055 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt index ff1464ecd..bfc827807 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=0.verified.txt index 75c016d20..cd2aa8760 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=0.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=2.verified.txt index f0f873f76..0724c8bbf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=2.verified.txt @@ -46,6 +46,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=4.verified.txt index e1f75b454..3f5f7b402 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=4.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=6.verified.txt index c20b95ce0..2a603c93d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=NullableString_implementations=6.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=0.verified.txt index dd58060f9..3641118b8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=0.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=2.verified.txt index bf40c1343..351fb99b0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=2.verified.txt @@ -46,6 +46,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=4.verified.txt index 502248aad..6ab2887d9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=4.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=6.verified.txt index 21cc181c6..8b31f69bc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=6_backingType=String_implementations=6.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=0.verified.txt index 66c8dfd4b..348716cf7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=2.verified.txt index c00275a08..b3811b0bc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=4.verified.txt index 3e6ce97c7..bbf5dfe6c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=6.verified.txt index ee0b2ddbc..30a58a497 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=0.verified.txt index 4def1dc19..ec6b1a869 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=2.verified.txt index 47208308d..7997169a4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=4.verified.txt index 56a6a2ac5..30f55c191 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=6.verified.txt index 33f257ee3..85bcc9780 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=0.verified.txt index 3af2366b3..ff820ff46 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=2.verified.txt index 9d11cc9f4..22f1c0ae7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=4.verified.txt index 0ece4a1da..b67e89084 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=6.verified.txt index ea6388564..68cddf12f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt index 656eaa0ab..4fd35d60b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt index f10a36609..520adcf61 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt index 0a2a00ef1..6e5ed9505 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt index 3e46e53fd..f83468d8b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ namespace Some.Namespace public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=0.verified.txt index e3f496128..fbb937e2c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=2.verified.txt index 16521789f..60e9f15ae 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=4.verified.txt index 0b4aaa7e5..cd6ca5fcd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=6.verified.txt index dc06fd196..e170f5d42 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ namespace Some.Namespace public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=0.verified.txt index 1dde2697d..438f5e818 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=2.verified.txt index 433a8a2db..58cc032f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ namespace Some.Namespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=4.verified.txt index 6cd314e1c..cae9ad663 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=6.verified.txt index 40c526dea..5f82a4a40 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=Some.Namespace_converter=8_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ namespace Some.Namespace public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=0.verified.txt index fad5ea0b5..07ef4dc9e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,4 +33,16 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=2.verified.txt index a13e9bec6..caf165051 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,4 +33,16 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=4.verified.txt index bef90429e..661bc713f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,5 +33,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=6.verified.txt index a71433af5..3a9d9b1e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,5 +33,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=0.verified.txt index 45272d34a..2f223e8cf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,4 +32,16 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=2.verified.txt index 5d23b64a1..969d0f321 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,4 +32,16 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=4.verified.txt index d76d3afd2..3b976a891 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=4.verified.txt @@ -32,5 +32,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=6.verified.txt index 15cde5ca8..c6a2b2f45 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,5 +32,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=0.verified.txt index af1658c35..8e42a939e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,4 +32,16 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=2.verified.txt index 13b9b1ac7..8393cf184 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,4 +32,16 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=4.verified.txt index c38fa63f6..4df096a5c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,5 +32,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=6.verified.txt index bdbc1a36b..26db5feb9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,5 +32,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt index 7e4892f41..c38d60030 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=0.verified.txt @@ -33,4 +33,19 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt index b4c2d5867..9777c3645 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=2.verified.txt @@ -33,4 +33,19 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt index 3a19fc65e..0f7386a7b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=4.verified.txt @@ -33,5 +33,20 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt index bf1288d0a..290f97abe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=MassTransitNewId_implementations=6.verified.txt @@ -33,5 +33,20 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=0.verified.txt index fe1e43665..b3bd45db3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=0.verified.txt @@ -41,4 +41,11 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=2.verified.txt index bb2e2c7d2..a1e594f0f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=2.verified.txt @@ -41,4 +41,11 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=4.verified.txt index d779d1af4..7b1d973c5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=4.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=6.verified.txt index 6692743d3..70a684d04 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=NullableString_implementations=6.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=0.verified.txt index 0987c7d64..3e70c8d0f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=0.verified.txt @@ -41,4 +41,16 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=2.verified.txt index 050bcc20b..4162df239 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=2.verified.txt @@ -41,4 +41,16 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=4.verified.txt index 4fae5139a..2246bd835 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=4.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=6.verified.txt index 71848e8ad..6dd7f9376 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=0_backingType=String_implementations=6.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=0.verified.txt index 286703fb7..afe4b9d08 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=2.verified.txt index 575acf33f..81c08d688 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=4.verified.txt index 429c9e636..8bbb8c911 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=6.verified.txt index dd329af56..0c8d2c89f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=0.verified.txt index d9a5fd157..8d6cd681a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=2.verified.txt index 6efcbabbd..af0eda481 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=4.verified.txt index cffea6f0f..76d27ff95 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=6.verified.txt index c8641b030..5a6912bc5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=0.verified.txt index 3cbd229f8..b4f188dfd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=2.verified.txt index 911e1df55..2ab2de501 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=4.verified.txt index 8651720dd..2678ca8fb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=6.verified.txt index 423662f1b..b9c86f9a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt index aff199193..7a74506bb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt index 0c038f47b..88a3eb4a4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt index 949ae457c..5ad98ffeb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt index 71c053d2a..215b0ee3f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=0.verified.txt index cbe27fcc7..3f245b5a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=2.verified.txt index b3c872f9e..2faa00af3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=4.verified.txt index d174ab5a8..df5343636 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=6.verified.txt index b506e0868..f637317ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=0.verified.txt index e0e6fa320..2f695fbeb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=2.verified.txt index 3f0d037d9..5bfda5851 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=4.verified.txt index f1e643c53..fe835e723 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=6.verified.txt index b5dc5e0a6..2c1038eaf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=10_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=0.verified.txt index 5b17bc763..ddfddca92 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=2.verified.txt index 8a35f4319..9a3063b05 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=4.verified.txt index 97397f8aa..ca2982272 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=6.verified.txt index 3b7c20735..2b0f910a5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=0.verified.txt index 2fbbad588..7220d9fec 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=2.verified.txt index b048ba8c8..ba57815f7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=4.verified.txt index 22475a156..bfa477717 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=6.verified.txt index 07c1753f3..205b264d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Int_implementations=6.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=0.verified.txt index 792e7e79c..a3f82b9b1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=2.verified.txt index 2fbc3067a..ad6bf8103 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=4.verified.txt index 64c7033dd..24f39cc25 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=6.verified.txt index 4b9c9b1ec..9b63f330c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt index e8e8bc433..fc536dcb3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt index 3ffd337e9..1cb74185a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt index 6b8fea618..4024309ae 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt index 03cf1b0f6..62e6e18dd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=0.verified.txt index a6b9e9a86..9db508508 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=2.verified.txt index 57ed2b88b..3f82f8ed8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=4.verified.txt index 1c4037a36..8779aeda6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=6.verified.txt index d769ffcdc..094239e3a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=0.verified.txt index 1ae453c1b..b328eda9b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=2.verified.txt index 70c1655bd..43a5046a4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=4.verified.txt index 949e8d650..8ca2bd0ca 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=6.verified.txt index 4f7a5b9d6..11ee59495 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=12_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=0.verified.txt index dbf3dc97b..88d1afad3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=0.verified.txt @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=2.verified.txt index f00df8fed..e76e78e58 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=4.verified.txt index 5c34f9f5a..257fd3a45 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=6.verified.txt index 9c0292883..30253765c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=0.verified.txt index edf1ced79..d281996f7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=2.verified.txt index 48dbb41fc..7d8e206ee 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=4.verified.txt index 123ee11ab..b0d72a4e5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=6.verified.txt index 8cde9ee80..fd34342dd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=0.verified.txt index a3efa273b..0d4630362 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=2.verified.txt index 0b736ec01..2deef3d6d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=4.verified.txt index 00a33f9d8..fcc44cc49 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=6.verified.txt index 6c511389f..3318949fa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt index ec68c34cc..8aab2e94e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt index ca3d5e712..8ea882941 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt index d3f7ad2cc..4e3766489 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt index 369f106de..ea4c58a2b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=0.verified.txt index 97458e49b..132a971cc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=2.verified.txt index a303bb4de..4c0b4ce4d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=4.verified.txt index c4202fd52..057fd8b36 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=6.verified.txt index 6b9e45859..20c0eabd6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=0.verified.txt index c9e5be871..b57f0a52b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=2.verified.txt index b4cc08fc6..c80514023 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=4.verified.txt index c2c43b3bd..85b038105 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=6.verified.txt index 16c357c4a..5d2794c3c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=14_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=0.verified.txt index 508208c37..ddbe61132 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=2.verified.txt index bd295d6c1..a674bdeb5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=4.verified.txt index 218054f51..8d427fce4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=6.verified.txt index 2c39146fd..9c016d636 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Guid_implementations=6.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=0.verified.txt index d3e50467b..7625f678c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=2.verified.txt index 57b00caf5..5b3d2cdad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=4.verified.txt index 3ad892329..ebf56e49a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=6.verified.txt index d6d3caa9d..a342243d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=0.verified.txt index cb5754863..da2ec3a71 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=2.verified.txt index 57a90b071..e51f9ee6c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=4.verified.txt index a745c3f85..5dbfd0cbb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=6.verified.txt index 69bd91feb..31627a452 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt index 9114f2d54..63e7b8d37 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=0.verified.txt @@ -34,6 +34,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt index a19ae7602..444b00c2b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=2.verified.txt @@ -34,6 +34,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt index 27986a9f0..2ca2f5d90 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=4.verified.txt @@ -33,6 +33,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt index a6ed5e90d..cf9a37009 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=MassTransitNewId_implementations=6.verified.txt @@ -33,6 +33,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=0.verified.txt index e1a174104..0110510b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=0.verified.txt @@ -42,6 +42,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=2.verified.txt index 8c854d1d6..6e15b78fe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=2.verified.txt @@ -42,6 +42,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=4.verified.txt index 32d805c45..de778c8ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=4.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=6.verified.txt index 5a34213ff..3c7932319 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=NullableString_implementations=6.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=0.verified.txt index 05700f78d..262de1f3b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=0.verified.txt @@ -42,6 +42,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=2.verified.txt index 434501443..45e0e0578 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=2.verified.txt @@ -42,6 +42,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=4.verified.txt index d6b9b51b1..accf53e65 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=4.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=6.verified.txt index d4cd1cfab..4a9979902 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=16_backingType=String_implementations=6.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=0.verified.txt index a5b390ae9..569bf0d84 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=2.verified.txt index e573e26b8..349ccd30e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=4.verified.txt index 47e26f681..69e80c273 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=6.verified.txt index 869f212bd..878637b46 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=0.verified.txt index 6016a2f1b..fd8276717 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=2.verified.txt index f2562c2ed..a64505d1d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=4.verified.txt index 75f28ad18..dd607ed2f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=6.verified.txt index e14dde339..614733329 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Int_implementations=6.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=0.verified.txt index 8a123daa5..679dbd1a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=2.verified.txt index 66632ba08..5d4c1f3e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=4.verified.txt index 76acb43d2..89eb4f2ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=6.verified.txt index ef65e5b9d..61de4e27b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt index 21911abb3..878f5a9ea 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt index 0f11a1a7a..b413cf919 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt index 03bb3fa3e..a933fa3dd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt index 82c259fd7..3f01c48e9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=0.verified.txt index b08c5c7e7..25a7a1199 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=2.verified.txt index f1d85f7ec..d018c0102 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=4.verified.txt index 179237606..88818c022 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=6.verified.txt index fe18c12e2..f8e623944 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=0.verified.txt index 5285d3a5f..737b349c3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=2.verified.txt index 056382da2..ecec4b94c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=4.verified.txt index 94305ce89..97367971d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=6.verified.txt index ffcef3c38..0ae616ca7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=18_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=0.verified.txt index f86ca50f7..a6e67d788 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=2.verified.txt index 67cee8d3f..c7cce4f04 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=4.verified.txt index 66d5c3199..08dd30deb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=6.verified.txt index 855f85d33..2943d4133 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=0.verified.txt index 4f9bb59c7..d5dab7112 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=2.verified.txt index cf0ea31f5..db5454dd9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=4.verified.txt index b657266e5..ffa9f2d9b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=4.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=6.verified.txt index 8c5cbf33c..6e1871884 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=0.verified.txt index 6718cc52c..9d813d6b8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=2.verified.txt index ff4ab817f..6f2b67c22 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=4.verified.txt index 6ca5cdcb4..98af7c943 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=6.verified.txt index 62179e110..993b6ecbc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt index 26caf885c..bbec5c04c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt index be7d6b36d..d1c3a2592 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt index e67be9210..dc40c7e7f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt index 75ec1dece..0336f56c0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=0.verified.txt index f02897f5e..3e8f8c4d5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=2.verified.txt index 0e75ad26b..96771f24e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=4.verified.txt index afc5cfe08..af5c29f31 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=6.verified.txt index d952e7455..6bbd497a7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=0.verified.txt index 192a5b115..ac967a2d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=2.verified.txt index 128fc9be1..f4613460d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=4.verified.txt index 4362f8ecd..c697ce53e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=6.verified.txt index 07c81818f..65b127fd1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=20_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=0.verified.txt index 5e1569b6b..253883f2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=2.verified.txt index 90e0deecc..5a074bb1c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=4.verified.txt index 3757efcdd..308f70e07 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=6.verified.txt index e397af5cf..3f6ea19ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Guid_implementations=6.verified.txt @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=0.verified.txt index 5671bb03a..adb262380 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=0.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=2.verified.txt index 070ac005d..b72402c1d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=4.verified.txt index d1700fa01..55efcbddc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=6.verified.txt index 9c2b9ddaf..41183903d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=0.verified.txt index 74e104457..c882da2d6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=2.verified.txt index 6c9ac56cd..ea52d2a05 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=4.verified.txt index db563c670..0c70ef990 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=6.verified.txt index 3492a3860..b6bc82e83 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt index 525829fd7..f22be7ac3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt index dfba40d2b..7c59c627b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt index 88b55d5c1..711b427d2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt index d4132d15c..3c5132147 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=0.verified.txt index b152548ee..ffb363fe3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=2.verified.txt index 4bf04caf1..5b29d3620 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=4.verified.txt index 168123d7b..b9f08a79d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=6.verified.txt index c57dbe822..21df7461d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=0.verified.txt index deb561040..e4017d307 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=2.verified.txt index 257930138..e9e93dd1a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=4.verified.txt index dc650d1b5..65b984f2d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=6.verified.txt index e31722493..461e0d361 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=22_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=0.verified.txt index 572994e92..75651494e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=0.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=2.verified.txt index e9deef96b..bfc1dff8f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=4.verified.txt index aebeabd1b..d5e34d4b6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=6.verified.txt index 88e82cd4c..d27f793ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=0.verified.txt index 9d057d1d5..0b72f322d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=2.verified.txt index 1f67e3e4b..028155991 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=4.verified.txt index fed6ab8b0..173e0839f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=6.verified.txt index 54704e2a9..c839dc771 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=0.verified.txt index c9e25364d..4dabea3d2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=2.verified.txt index b42ebab87..bf9929ba0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=4.verified.txt index f340a7c78..6c76ac99f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=6.verified.txt index d9fcaa98a..ebdf9eccf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt index 6944698c0..303b8f306 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt index 3daccfb38..f40957bab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt index f29079f7d..c844705e5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt index f81ef28ae..a422fb3f5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=0.verified.txt index 2b0132b16..b7b9f6edc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=2.verified.txt index 317ab3263..a23568372 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=4.verified.txt index 0289c9f19..a37e8b73a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=6.verified.txt index 914399097..898900dcd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=0.verified.txt index 1fee9cda6..d51856939 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=2.verified.txt index 740c042b7..534f6e192 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=4.verified.txt index cb2ef177b..e72d86da8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=6.verified.txt index 8d6d969f1..343ad050d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=24_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=0.verified.txt index c1552f596..878db4ac0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=2.verified.txt index 764750b7a..085cdff53 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=4.verified.txt index ef0ee8b70..627b9ceb7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=6.verified.txt index 15719bcb6..a86986dcf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=0.verified.txt index 3edba7f5e..0d801ffa5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=2.verified.txt index 4fa0b420d..f91200dde 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=4.verified.txt index e1c40915d..0af5f257a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=6.verified.txt index c261528c6..f50800eb1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=0.verified.txt index 16cf6d87e..61a45b06a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=2.verified.txt index 6f5ac7b23..c14edf59e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=4.verified.txt index 4bbcc932a..34bc787b2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=6.verified.txt index f3eb336e3..eb8393d26 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt index 16bcadc15..084a565e9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt index d6c44f612..bef6f04b6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt index 37df716f2..e4277f124 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt index 2ea93b29e..994d330f8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=0.verified.txt index c82e4cc63..8124b7456 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=2.verified.txt index 18299ba3f..fc83c0a51 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=4.verified.txt index 618922eb9..bab151a30 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=6.verified.txt index 346ddee65..f00ce96ac 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=0.verified.txt index 244ba4867..b763abe99 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=2.verified.txt index 8c07e6839..96e5dd951 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=4.verified.txt index b55e5f5e1..895420837 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=6.verified.txt index abbd107de..28b9c4f5a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=26_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=0.verified.txt index ffa130f3d..5e7baba0f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=2.verified.txt index 84879e5ed..3a749a5d4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=4.verified.txt index 28f65ef8c..12a568c61 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=6.verified.txt index 19344a1c3..a5e9cd10e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=0.verified.txt index f1a2afbf1..298746e43 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=2.verified.txt index 18c5e7a5d..e9f8a1247 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=4.verified.txt index d7f221f75..0e9377cb0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=6.verified.txt index 5674055a8..a4780b263 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=0.verified.txt index fff8e297c..e08de01cf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=2.verified.txt index 4d6f17df0..06509c15a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=4.verified.txt index c5f5fbcad..384f221fe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=6.verified.txt index 036787a5a..13095a3f9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt index a5e0fc9c0..cde9ca7ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt index 504828737..5bf953ec8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt index 36c4b6df5..2a6d087ec 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt index 5b54c1374..e13457b15 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=0.verified.txt index d91e57826..c32b40b41 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=2.verified.txt index 566904314..4300b68e4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=4.verified.txt index 4e9f8888f..a1a8a1242 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=6.verified.txt index 4059ad5cf..7b0e8edd2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=0.verified.txt index b566ab9bf..34e34ac1f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=2.verified.txt index 3973cb928..bb2b0a41f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=4.verified.txt index 1db1de572..4fef48734 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=6.verified.txt index e82724e02..20c02fabe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=28_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=0.verified.txt index 295e92baf..563886593 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=2.verified.txt index 0077e4022..3dc7bb08a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=4.verified.txt index 14b9c5b84..fbf91fc3e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=6.verified.txt index 13196ae6a..d7a73cb88 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=0.verified.txt index 39f1e9331..3bfd1ff90 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=2.verified.txt index 7f290a4bf..cc170fc40 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=2.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=4.verified.txt index 8ce140c59..a5201b8ec 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=6.verified.txt index d90e44f0a..835bcae86 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=0.verified.txt index e22d0478c..ed6247771 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=2.verified.txt index e59f029cf..a69387839 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=4.verified.txt index bb00244bd..27e6c7775 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=6.verified.txt index 6c4e3b355..64b1ebefd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt index 757eb4ebb..6d11a9d03 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt index 2e3626019..386b1ccad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt index 8815c1a53..45d17f6a0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt index c9dc48985..1cfd19d4f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=0.verified.txt index 50b3c0585..356829879 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=2.verified.txt index 9998098e1..971646957 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=4.verified.txt index fe59fe488..74dd43a27 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=6.verified.txt index fef3e3ef6..608d81d4e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=0.verified.txt index d35ac20a3..e7b270297 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=2.verified.txt index d494488e1..d35361d4b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=4.verified.txt index 18075710c..da0909f3a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=6.verified.txt index 764a61f97..a31369cf7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=2_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=0.verified.txt index 957c09cb5..7fa861b0e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=2.verified.txt index 22978188c..c8ff41551 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=4.verified.txt index aad522deb..c9a89c68b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=6.verified.txt index 80bbfe1a5..c73d643d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=0.verified.txt index da8e84ba4..b6350862f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=2.verified.txt index a89f12ed3..13ab339b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=4.verified.txt index 7f20719fe..65aa3e29b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=6.verified.txt index 255308e13..6f0903512 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=0.verified.txt index 22a36bb65..eecc42929 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=2.verified.txt index 3821a625f..d05b8204d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=2.verified.txt @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=4.verified.txt index 878302f71..09ee169b7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=6.verified.txt index d899d420a..2935b2a3d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt index 916562a93..3ea10122b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt index 2e4a98f29..2958ae215 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt index 254a4e59f..4cbb46bc6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt index 2a617360b..f6f3e5bed 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=0.verified.txt index 122f0717d..d6211bf02 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=2.verified.txt index 51b9e932d..9fd5d24df 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=4.verified.txt index 0a2215584..ef4733c2f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=6.verified.txt index 90ef72e80..052f22c45 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=0.verified.txt index 57e99b36d..4d76ed340 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=2.verified.txt index 24e80a1a9..3b1890b17 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=4.verified.txt index 0fa2b35f2..c082ec909 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=6.verified.txt index 8dc109405..bcd4e0b92 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=30_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=0.verified.txt index bb6b344ab..c09eb9b20 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=2.verified.txt index dc3548e2a..bbe60bb51 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=4.verified.txt index 0d618f5be..ff28c4388 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=6.verified.txt index 6322877e4..5e23e6473 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=0.verified.txt index f8d24bbf5..c3c291e72 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=2.verified.txt index 3d3dbec95..5cfdc3c05 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=4.verified.txt index b9fcc345d..beb2e7941 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=6.verified.txt index 7873f1c08..ed3e0d8bf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=0.verified.txt index 35fd482b5..6d673eb6d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=0.verified.txt @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=2.verified.txt index bf29f0632..d4f3159bb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=4.verified.txt index 8c4c6b8ca..ee0b657ba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=6.verified.txt index f2f3265ad..c79dce0d8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt index 23efe4b09..93697414b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=0.verified.txt @@ -34,6 +34,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt index 5a4844ff5..58ca2c5d7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=2.verified.txt @@ -34,6 +34,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt index e52a905ae..9a1817592 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=4.verified.txt @@ -33,6 +33,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt index 7acf87609..70de11cd4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=MassTransitNewId_implementations=6.verified.txt @@ -33,6 +33,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=0.verified.txt index c96f1e168..fbe6d52f8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=0.verified.txt @@ -42,6 +42,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=2.verified.txt index aad0a6a09..5a0768bb8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=2.verified.txt @@ -42,6 +42,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=4.verified.txt index 8e82c6b0a..dd861b3d9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=4.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=6.verified.txt index 9c8f31fbd..d79adfd3b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=NullableString_implementations=6.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=0.verified.txt index 749dd1dbd..35f6abb1f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=0.verified.txt @@ -42,6 +42,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=2.verified.txt index b02959a47..f2fffc755 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=2.verified.txt @@ -42,6 +42,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=4.verified.txt index e578dc79d..afcf935d8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=4.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=6.verified.txt index 618b8fd68..bd5521338 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=32_backingType=String_implementations=6.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=0.verified.txt index b57a771a7..311f60501 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=0.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=2.verified.txt index 832df2f45..767d5f2cd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=4.verified.txt index e369b1c0a..0c79697b2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=6.verified.txt index ac6ec3fb5..9bff508f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Guid_implementations=6.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=0.verified.txt index 0a944fe22..0d33625e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=0.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=2.verified.txt index 8d865d6e4..7eb2c5309 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=4.verified.txt index 433c8ee89..862393898 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=6.verified.txt index d71f87cb7..973b43161 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Int_implementations=6.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=0.verified.txt index 30ed97239..2f2b56c25 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=2.verified.txt index 242b9b429..67309c749 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=4.verified.txt index 25ac8a749..ea07c9b35 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=6.verified.txt index bad14ec8f..acda7f232 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt index dd28f587a..220efe477 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt index 51678630a..559f02bc3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt index bdd592744..5a50050ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt index 9a181e72e..1cfdcbfbc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=0.verified.txt index f1cd60de0..b960c7947 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=2.verified.txt index c0a90b653..9b37a78f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=4.verified.txt index 845256fe4..eb3bffb95 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=6.verified.txt index 4688bd2c6..949ab168d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=0.verified.txt index 0273a18c5..87bdbf53f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=2.verified.txt index df9ee5ce2..ab460d823 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=4.verified.txt index 8aac244ba..933c1db97 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=6.verified.txt index 9fd9bf233..6a802a297 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=34_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=0.verified.txt index bb28ace7d..94eb74a14 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=2.verified.txt index 261e18a04..4cbd49137 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=4.verified.txt index d5cf93218..9b040bcda 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=6.verified.txt index d13a1c2fb..b3e8a70cc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=0.verified.txt index b3adbbbbd..2b99be456 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=2.verified.txt index 41b54f5dc..4a69d7cd1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=2.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=4.verified.txt index 5c4151f1b..0afd47de9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=6.verified.txt index d5f3adf52..d8ab3934c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=0.verified.txt index 3489c199c..a15058add 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=2.verified.txt index 7a5098179..c8cdd57a5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=4.verified.txt index d22975491..38b17d3f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=6.verified.txt index 1b54191f0..5abe99cfc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=Long_implementations=6.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt index 512453f5b..0b3e007f0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt index 704e363db..abbf09dba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt index 6991bdcad..6b38975f1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt index 9198a79c6..ef7544ae8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=0.verified.txt index 11ebc571a..f91dabb5f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=2.verified.txt index 75233ccbc..e60e1c925 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=4.verified.txt index d3ff8ac16..de1b51a45 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=6.verified.txt index 5e6d39560..2ff0abd2b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=0.verified.txt index e43dfc261..fdfd656e2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=2.verified.txt index 1cf64c254..0d3980303 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=4.verified.txt index 01ab732cc..10a11a64a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=6.verified.txt index 5bd8609ee..d3db2065e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=36_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=0.verified.txt index b3d5544a1..7be00d957 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=2.verified.txt index 924f53f63..82de07e5a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=4.verified.txt index 51a920151..9e524517c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=4.verified.txt @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=6.verified.txt index 6434a369e..5042add55 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=0.verified.txt index 9daf502db..0b43cb424 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=2.verified.txt index 8a2593749..540b06f15 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=4.verified.txt index b4d591ba6..4647775f5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=6.verified.txt index 638ff54c1..9d232fff6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=0.verified.txt index e0d882cfe..bfaec2880 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=2.verified.txt index de46e82af..5463b5e9a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=4.verified.txt index 8960e2f29..858b18690 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=6.verified.txt index cae3c90bb..fc3334934 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt index ebd81272a..fe3ffef3e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt index 655494b9d..63012bb1d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt index ae2203eed..61f7ab50a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt index 9dd394aac..29d274729 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=0.verified.txt index 87b7218c3..0d81aef87 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=2.verified.txt index 050374b9a..8ed18d8f7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=4.verified.txt index 2f80ee55a..94148ff00 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=6.verified.txt index aa9a49efe..dc7f9f6c7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=0.verified.txt index 8d2a55257..ffc9d02b4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=2.verified.txt index 948e36217..863edb760 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=4.verified.txt index f24213115..dfcd70619 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=6.verified.txt index 894f2956a..1e2e71024 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=38_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=0.verified.txt index bcc72a24e..98a656a12 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=2.verified.txt index a5fc2d427..d7cc9a803 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=4.verified.txt index 50be52654..b848d6248 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=6.verified.txt index 4a23f21e7..8e17f8dcf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=0.verified.txt index e137aa982..ab8c754f0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=2.verified.txt index f937a8c86..74fc27069 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=4.verified.txt index 214c81c62..37314b60d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=6.verified.txt index 4f709ab9f..0397d1566 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=0.verified.txt index b088e7a4d..e6721a62b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=2.verified.txt index 409885ba3..980817340 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=2.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=4.verified.txt index 39fc61578..babe40c79 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=6.verified.txt index 1f51fdb77..a9e8ef94a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt index 6317ec8c9..239cc93e5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt index 15b869d38..21c262a53 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt index 105461c71..a18047299 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt index 37b4f5555..b07fe3ba6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=0.verified.txt index b13927557..4b6f6bcb5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=2.verified.txt index 46a888d0c..d4e54945e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=4.verified.txt index 20e37f901..091eb525f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=6.verified.txt index 3e1ea39d9..3a32a1d22 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=0.verified.txt index 6bab2f4b2..b2548358e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=2.verified.txt index 4f04572cb..358f9a6c9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=4.verified.txt index 74054d2a6..20149deac 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=6.verified.txt index f8c1ffc05..757769472 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=40_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=0.verified.txt index a01ae92f3..23b8609d8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=2.verified.txt index faf04c450..9dcd6bafb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=4.verified.txt index bcddc13ae..76f711432 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=6.verified.txt index f0489a598..888e11cf9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=0.verified.txt index 4c59f582c..5e5db121b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=2.verified.txt index de9165d11..9e73e6897 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=4.verified.txt index eca73bf3d..991b5adcc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=6.verified.txt index e6c438076..c805a7f46 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=0.verified.txt index f090ee732..7a93a3f5b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=2.verified.txt index c5ef1bf9e..e782c7cf7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=4.verified.txt index 98c864fd4..2f02a7f50 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=6.verified.txt index 3aadcba04..ab05054f8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt index 5691ea1c8..4e4458c7c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt index 6a7c563f3..260a4943f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt index 731e9a121..05fe22fd6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt index c55e0c859..fae28fb44 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=0.verified.txt index 2dede43b8..20614587c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=2.verified.txt index d1502e926..ab4eec911 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=4.verified.txt index c69bfcdae..b87982c61 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=6.verified.txt index 09ddd15e3..d655d64bb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=0.verified.txt index ba32aeb6a..33e1da427 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=2.verified.txt index 08432d533..7f10270bc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=4.verified.txt index 16ff6b10b..00d78132e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=6.verified.txt index 19bde9849..aa6a5a7f9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=42_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=0.verified.txt index 96cd1f614..19ca999f8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=0.verified.txt @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=2.verified.txt index 7f21da81c..a7a4538b1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=2.verified.txt @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=4.verified.txt index 1c0bf0cbd..a7c8e6b13 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=6.verified.txt index 8621fda3d..e71f37901 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=0.verified.txt index 440f27b4d..018c41694 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=2.verified.txt index 80d9263cd..8bc73f25e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=4.verified.txt index 3ef072221..3dbc1e6f6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=6.verified.txt index b6d8d3e88..9112cd186 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=0.verified.txt index 239e6df24..1a89fedb3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=2.verified.txt index bdb2925c7..277a99156 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=4.verified.txt index c17c1e7c2..7b6ebbc5b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=6.verified.txt index f30ed321b..333f842e7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt index 6b632b80b..1beb21d5c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt index 61cc7bbf5..3a42a20de 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt index 70ae1db31..befe3a73a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt index e9deecda3..efdb83bdd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=0.verified.txt index ba83b517d..4a957f843 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=2.verified.txt index 3c12aac76..8abd7af6a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=4.verified.txt index d19feaaef..f691cf85b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=6.verified.txt index 6f7ae5a7f..a44ebbea8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=0.verified.txt index a900164db..954d161b1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=2.verified.txt index 1cabcefb0..3b9fffa7e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=4.verified.txt index 322c7a1b3..8558cda49 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=6.verified.txt index 2f261fc03..c92de2843 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=44_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=0.verified.txt index 1155125e3..36e367eae 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=2.verified.txt index 97f584feb..6ca8b7589 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=4.verified.txt index bde680ba2..b958057f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=6.verified.txt index 75e03cbe7..a6909b1d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=0.verified.txt index 5d986e20d..2547bd004 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=2.verified.txt index aa3bb40ac..1b4267a19 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=4.verified.txt index 605113f2d..f383dd2d2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=6.verified.txt index 9c801822e..b68adcd82 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=0.verified.txt index 3e1553591..2a1c1e4d0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=2.verified.txt index df3138ff5..00ec0eb1d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=4.verified.txt index b5b6abe3e..7d41c5241 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=6.verified.txt index f770fb33b..d013c1a27 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt index 083d9988d..9474eb200 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt index a1fd14438..1e0eb8385 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt index 0f3a9fefb..e97ec6001 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt index 75a76bc9a..2c8b5ddc0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=0.verified.txt index c3dba160d..8b54748d5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=2.verified.txt index f9b1a2b81..238d43b56 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=4.verified.txt index 05c0e46f0..3d8515c73 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=6.verified.txt index f72928be9..1109797d8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=0.verified.txt index 87e14f633..86bd32be6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=2.verified.txt index 9a61a45a0..d905f4666 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class DapperTypeHandler : Dapper.SqlMapper.TypeHandler { public override void SetValue(System.Data.IDbDataParameter parameter, MyTestId value) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=4.verified.txt index 7be93268d..820fd2441 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=6.verified.txt index e737676ea..9626204db 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=46_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=0.verified.txt index d7f316217..1675f37b7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=2.verified.txt index 298bcbcc8..4af9bd4b9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=4.verified.txt index 812a1b5f4..3d9f4cfad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=6.verified.txt index 2ab13c905..9a9c73758 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Guid_implementations=6.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=0.verified.txt index a5f5102e4..c9b46ad25 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=2.verified.txt index d9d59241a..6310f02d4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=4.verified.txt index 4a3a7fc71..751e00c3e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=6.verified.txt index aecca7dd5..2783ae82e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=0.verified.txt index e4f6e79db..824063e30 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=2.verified.txt index 094e8c23a..039d4043a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=4.verified.txt index 42f4d0210..4233032e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=6.verified.txt index 1f0d97b99..0b8f2ba06 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,6 +32,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt index 364f4ee69..6be985985 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=0.verified.txt @@ -34,6 +34,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt index e081ff189..c6c75b817 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=2.verified.txt @@ -34,6 +34,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt index 217526534..40a130383 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=4.verified.txt @@ -33,6 +33,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt index 4b3401ec1..907daee63 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=MassTransitNewId_implementations=6.verified.txt @@ -33,6 +33,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=0.verified.txt index 0f9087431..2dd6e24fe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=0.verified.txt @@ -42,6 +42,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=2.verified.txt index ceb1027d1..204ca098c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=2.verified.txt @@ -42,6 +42,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=4.verified.txt index 61cfbcec7..80330881e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=4.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=6.verified.txt index 76a26bdc5..a8c5c32f4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=NullableString_implementations=6.verified.txt @@ -41,6 +41,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=0.verified.txt index 23e682e43..b051b25c4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=0.verified.txt @@ -42,6 +42,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=2.verified.txt index 089091ac6..6466120f6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=2.verified.txt @@ -42,6 +42,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=4.verified.txt index a7874f522..714155cba 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=4.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=6.verified.txt index e4e666918..20a06ebf2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=48_backingType=String_implementations=6.verified.txt @@ -41,6 +41,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=0.verified.txt index db59f66c1..06ddad367 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=2.verified.txt index 87420f08f..e634902b8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=2.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=4.verified.txt index 420ee5f2d..3d7529e8f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=6.verified.txt index 61ed433f2..f2a1336bd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=0.verified.txt index b4d9738e7..d6cc421ac 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=0.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=2.verified.txt index 5dec9d086..5ebacaaf9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=4.verified.txt index 2da11bf8f..03e62db62 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=6.verified.txt index cdd5780df..3e2f9dbe0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=0.verified.txt index 7052a3b27..5169e4827 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=2.verified.txt index a3ab351fb..55a74bfbd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=4.verified.txt index 5e6714afd..ee9735d67 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=6.verified.txt index ca9e4c4b2..62cddd206 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt index 181d85e44..501776750 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt index 0f26b0e78..085e71b8e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt index e42ad1a59..a230fd226 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt index bbd694af0..346ee556b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=0.verified.txt index 9660c1fc0..c80f215e9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=2.verified.txt index c60dab4e5..2865c5295 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=4.verified.txt index e1854a2a6..f631e1e5d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=6.verified.txt index 852c14d3a..60838ce44 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=0.verified.txt index a84cc6ce1..2f3feca0f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=2.verified.txt index df085d248..70655563c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter { public override bool CanConvert(System.Type objectType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=4.verified.txt index e610ab482..1c65907ca 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=6.verified.txt index 6ec82fd89..ab77ec7bf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=4_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=0.verified.txt index 73747b40e..ca98be496 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=2.verified.txt index 65cc2b302..d9f7a6a52 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=4.verified.txt index d6de41627..390d87f77 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=6.verified.txt index cc5f8ebe1..d95bd2e95 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=0.verified.txt index 327e8c897..7d991e7f7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=0.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=2.verified.txt index 0bd6478f4..02079a94c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=4.verified.txt index 1113add5e..b2b4c4667 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=6.verified.txt index 277861014..aeafc9d47 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=0.verified.txt index c2a005a0a..39d5b8001 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=2.verified.txt index c27caa895..bbb7d68ad 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=4.verified.txt index 249cfaa30..f0d681139 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=6.verified.txt index a6ee535d0..5134e10a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt index b7a76391e..0f04d264f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt index 1f68b3944..baa75a1ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt index 465ed2765..f0f6d0056 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt index df9710d18..7fe3bcb6c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=0.verified.txt index d45d5ba96..188710865 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=2.verified.txt index 72d066eed..84e74a6be 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=4.verified.txt index a570cba8c..b1c80a9c6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=6.verified.txt index c6c85290f..049e0220b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=0.verified.txt index 068586486..9e3d65cf6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=2.verified.txt index fec0ea51e..2711fbde4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=4.verified.txt index 2101be3b1..fa0a08cfc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=6.verified.txt index 1c32948f9..f3cadcb19 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=50_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=0.verified.txt index a22b1513b..522d387bb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=2.verified.txt index 5fae89961..2e874b301 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=4.verified.txt index 809e649a4..f2fdc6e38 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=6.verified.txt index 541e7f9f5..422e3b3d6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=0.verified.txt index cc21919b7..305e37e21 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=2.verified.txt index 067afdeaf..b1c55175a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=4.verified.txt index 977ab2987..3265116cf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=4.verified.txt @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=6.verified.txt index 7e54c92f3..c24ef8e64 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=0.verified.txt index c46d8b99c..3d4fea707 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=0.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=2.verified.txt index 44d62b358..689e88acf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=4.verified.txt index 8ea7a51aa..9fa039492 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=6.verified.txt index 2d1d13de7..edf38540b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt index 3625cc5e9..0d105113e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt index d67f37118..c1194ebd1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt index 57e4b6b43..6792b32e0 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt index 5f0d28d18..cec0098fe 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=0.verified.txt index 5070b4607..1fa2cef5a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=2.verified.txt index d35e96a2a..2b25cd746 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=4.verified.txt index f52a533e5..1a50299de 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=6.verified.txt index c76213373..186b1324b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=0.verified.txt index 161c670cf..1586bb6ec 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=2.verified.txt index 642b0814b..2cb9a8804 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=4.verified.txt index bd185b336..759caa691 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=6.verified.txt index d52bbd560..29727d57a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=52_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=0.verified.txt index bd4ae8b8e..8d6755e87 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=2.verified.txt index 2359feffa..06017e526 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=2.verified.txt @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=4.verified.txt index 468a3abbf..a6f46b72e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=6.verified.txt index 603d6c184..cf162edc9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=0.verified.txt index ded8f2ab7..3f956269b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=2.verified.txt index 05611cab9..c734c5b37 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=4.verified.txt index 753376c71..05a0bcf31 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=6.verified.txt index ba470f0ae..c747bd316 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Int_implementations=6.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=0.verified.txt index a8f0ac31d..6b76af734 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=2.verified.txt index bfda82ce1..77751777b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=4.verified.txt index b5fcd80eb..4134f4c81 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=6.verified.txt index 983cd47f5..13dfee31d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt index b1077cc0d..b0c868f5f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt index 947e52280..2823941e7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt index 3708aff57..23c871116 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt index 5ccb54260..3cb82026e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=0.verified.txt index 2d45407d8..8c1416e71 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=2.verified.txt index a63456868..94d9252cf 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=4.verified.txt index 3a27622d8..e7d824818 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=6.verified.txt index dece7e706..1ea2cb9d9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=0.verified.txt index 89c1e3081..b2085c2af 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=2.verified.txt index f47d1356f..165305b74 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=4.verified.txt index c870e4b5f..97572b268 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=6.verified.txt index 39016c9ce..c2780685f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=54_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=0.verified.txt index c7c6026fa..4deb23f7c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=2.verified.txt index 83e7701cf..8c4e1bcd6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=4.verified.txt index 25a5bdd7f..df14eb060 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=6.verified.txt index 2f3fc1848..4369a9585 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=0.verified.txt index c57f81435..5cf5d4070 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=2.verified.txt index d0646dc1f..da449bceb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=4.verified.txt index 37da18f5d..ab58dfa87 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=6.verified.txt index 5cc2aa633..772856580 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=0.verified.txt index fee9af854..b7541da52 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=2.verified.txt index bcd1d22f5..3c9548ed8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=4.verified.txt index f83fe861f..e7159df6e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=6.verified.txt index ae9b13330..5a5694621 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt index e96bc876c..1c46c12ee 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt index 3bee868b1..de55f9cbb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt index 197f2e3c5..ec3362835 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt index af9fc1c86..a2500960d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=0.verified.txt index 4db7f13cf..ff36c526e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=2.verified.txt index acea8c1cb..cbfa97db9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=4.verified.txt index e212e4a52..0f3468fce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=6.verified.txt index c568da073..8efe24ac3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=0.verified.txt index ccf45c8b2..c4052e589 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=2.verified.txt index fcaa1787f..892ba6afc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=4.verified.txt index 6103899de..33e79e304 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=6.verified.txt index 7b2a66336..a20d02622 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=56_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=0.verified.txt index 32c0c0bf3..60723410f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=2.verified.txt index 421db02d3..bba7d7c6f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=4.verified.txt index 40f88a91f..59c0a8266 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=6.verified.txt index dfc48fcb4..e934e48ed 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=0.verified.txt index d3928373d..c35365e90 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=0.verified.txt @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=2.verified.txt index 2a2c93ce9..79f750070 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=4.verified.txt index 61aa61a65..892ee7749 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=6.verified.txt index fa2294ac1..7908cde19 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=0.verified.txt index c518dc45b..ecae8775c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=2.verified.txt index 82303f637..d2f6ed1a3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=4.verified.txt index 52ead0c20..6470ed5c7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=6.verified.txt index 60cef5093..0ae4eef4e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt index e6dce1d6f..37b729e54 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt index 24bae0d08..307bf4769 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt index 537722559..66c465655 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt index 9a63c516b..3ec6efd52 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=0.verified.txt index 8e6e75e9c..af686578d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=2.verified.txt index e75699f41..2e4165f77 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=4.verified.txt index c8681b17a..165b44361 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=6.verified.txt index c140f9f6c..61ca12cd4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=0.verified.txt index 79507c7c7..146bedffd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=2.verified.txt index 4e52f416b..ee0cbfd7f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=4.verified.txt index b8933f370..09ef4489c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=6.verified.txt index 592f4838c..1e5f3eef5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=58_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=0.verified.txt index 708ea8be0..b015893a2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=2.verified.txt index 19b9b069f..644d84b10 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=4.verified.txt index 3790316cb..3a70e5c7a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=6.verified.txt index fe4e5e00a..5a67d3841 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=0.verified.txt index 4a0f22752..3e158aba8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=2.verified.txt index 1bb8a428f..313595e8a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=4.verified.txt index 10f78b6e0..3251c2486 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=6.verified.txt index 72f8c2993..d3032f1f9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=0.verified.txt index 03ed0affb..22572c741 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=2.verified.txt index 4b8095558..0a37c279f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=4.verified.txt index 0d57ec71d..d9835d068 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=6.verified.txt index b241c0dae..da4dc1f36 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt index 94d702dcd..68651f8e3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt index 3fcc2e9de..146898cce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt index 967312182..fa81ac760 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt index bf8ff9b8f..a43aad76d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=0.verified.txt index 065473715..9e95b0870 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=2.verified.txt index a19864428..575457f67 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=4.verified.txt index ce3f82c10..39f5b5f54 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=6.verified.txt index d3157fd3c..5e4a8102f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=0.verified.txt index fd38636bd..7f96567b2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=2.verified.txt index c08311fd4..edcf4b946 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=4.verified.txt index e4423be80..ce6677606 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=6.verified.txt index e39b22e3b..0bfda05e7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=60_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=0.verified.txt index 4cd97ce30..076cdfb27 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=2.verified.txt index 71ea2e49a..568f67913 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=4.verified.txt index 72f4e6109..ffb60ebbc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=6.verified.txt index d7a3ed3e7..df211f1a9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Guid_implementations=6.verified.txt @@ -36,6 +36,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=0.verified.txt index 6d0e78a37..3e7019a1a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=2.verified.txt index dd6174a7a..98dccc142 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=4.verified.txt index a9fbb7dad..513975773 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=6.verified.txt index e7affbacb..653fa4058 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=0.verified.txt index fda121d39..8b540885e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=2.verified.txt index 2668f3565..d562d969e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=4.verified.txt index 8b214d048..73925f688 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=6.verified.txt index 0a464e952..25554cbab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt index a0cd60118..3dfa6d0d4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=0.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt index 3bbe920dd..4e7f02faa 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=2.verified.txt @@ -37,6 +37,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt index a65656a92..a3fbfb5cb 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=4.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt index c2c044246..67cefccd7 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=MassTransitNewId_implementations=6.verified.txt @@ -36,6 +36,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=0.verified.txt index 2f400121e..c4b121edd 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=0.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=2.verified.txt index 7f1c02ab3..75ac6b4b6 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=2.verified.txt @@ -45,6 +45,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=4.verified.txt index 1bdc4fdad..206130135 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=4.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=6.verified.txt index 975c29ade..6c822306f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=NullableString_implementations=6.verified.txt @@ -44,6 +44,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=0.verified.txt index a61773a56..e6968e40e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=0.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=2.verified.txt index 8577f5664..825063729 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=2.verified.txt @@ -45,6 +45,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + public class EfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter { public EfCoreValueConverter() : this(null) { } diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=4.verified.txt index fa61366bc..7dad41688 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=4.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=6.verified.txt index d97757d42..5c29cd732 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=62_backingType=String_implementations=6.verified.txt @@ -44,6 +44,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=0.verified.txt index 16144f138..bf14a9148 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=2.verified.txt index 96d80812e..a4b262f8f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=4.verified.txt index dbba1df2a..5f4c195ce 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=6.verified.txt index 72a136aa1..24d484ef4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=0.verified.txt index 7cc59718a..c8a26a599 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=2.verified.txt index 89c6fca8b..72cb7f1e5 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=4.verified.txt index 84b907c24..6d571d348 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=6.verified.txt index cb0e29b0d..53b19fa19 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=0.verified.txt index 612820c2f..49e597c9a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=2.verified.txt index c46f2e092..d4a479e0a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=4.verified.txt index 9eba7b0bc..51b3d4371 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=6.verified.txt index 2318cbc65..bad4d33c3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt index 0a0b6d7a9..d774cb3af 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=0.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt index cc52d07fd..5a2746491 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=2.verified.txt @@ -36,6 +36,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt index 89301b5d7..fa810ad03 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=4.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt index 1dfa457eb..9e1c1e898 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=MassTransitNewId_implementations=6.verified.txt @@ -35,6 +35,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=0.verified.txt index e38f26e7c..fbfe5ebe2 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=0.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=2.verified.txt index ee9fc9d3e..2b0b95958 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=2.verified.txt @@ -44,6 +44,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=4.verified.txt index 86981b486..2718b8b8e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=4.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=6.verified.txt index d067e2f1d..5cd08298d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=NullableString_implementations=6.verified.txt @@ -43,6 +43,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=0.verified.txt index a09dda7f8..683d88b10 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=0.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=2.verified.txt index 37aa96d39..fa2ac73ab 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=2.verified.txt @@ -44,6 +44,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdTypeConverter : System.ComponentModel.TypeConverter { public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=4.verified.txt index 529eccdf4..79884bdcc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=4.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=6.verified.txt index 19845b0f8..ed6629a92 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=6_backingType=String_implementations=6.verified.txt @@ -43,6 +43,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=0.verified.txt index d6d801a99..137860f07 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=2.verified.txt index 035d403a7..7fbdff603 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=4.verified.txt index 864fdcaed..101820aed 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=4.verified.txt @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=6.verified.txt index 6d8214a6e..34c3e830f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Guid_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=0.verified.txt index 7c016c3be..ebe9b82b3 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=0.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=2.verified.txt index 398c4983b..0efe23875 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=4.verified.txt index a8887e507..6cb4292ef 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=6.verified.txt index 741a27dbf..be5f6c022 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Int_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(int.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=0.verified.txt index 17a45333f..7a522763f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=0.verified.txt @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=2.verified.txt index 7f65e548d..e361ceb4b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=2.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -34,6 +34,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=4.verified.txt index 323a04ec0..b05882903 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=4.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=6.verified.txt index 777b203cd..50affbf98 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=Long_implementations=6.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -33,6 +33,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(long.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (long.TryParse(value, out long parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt index 3de0600ab..3a897cb2a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=0.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt index 31d84c7b2..0fd0137cc 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=2.verified.txt @@ -35,6 +35,21 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt index a1a6faa50..39908d5a4 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=4.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt index c71902078..2a1918262 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=MassTransitNewId_implementations=6.verified.txt @@ -34,6 +34,21 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(new MassTransit.NewId(in value)); + public static bool TryParse(string value, out MyTestId result) + { + try + { + result = new MyTestId(new MassTransit.NewId(in value)); + return true; + } + catch + { + result = default; + return false; + } + } public int CompareTo(MyTestId other) => Value.CompareTo(other.Value); class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=0.verified.txt index c049fb7f5..8db3b3557 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=0.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=2.verified.txt index 27b0a2df2..02501802d 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=2.verified.txt @@ -43,6 +43,13 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=4.verified.txt index b8035d08e..4afb87430 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=4.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=6.verified.txt index 03d66b825..2723d5b0b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=NullableString_implementations=6.verified.txt @@ -42,6 +42,13 @@ public override string? ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string? value) => new MyTestId(value); + public static bool TryParse(string? value, out MyTestId result) + { + result = new MyTestId(value?.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=0.verified.txt index 1396ccae3..0616d5707 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=0.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=2.verified.txt index a250192a6..7d3e0751a 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=2.verified.txt @@ -43,6 +43,18 @@ public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=4.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=4.verified.txt index 0b2bca560..a95b4d255 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=4.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=4.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=6.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=6.verified.txt index 8c22ba6e8..b65f33b29 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=6.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdCorrectly_ns=_converter=8_backingType=String_implementations=6.verified.txt @@ -42,6 +42,18 @@ public override string ToString() => Value; public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + + public static MyTestId Parse(string value) => new MyTestId(value); + public static bool TryParse(string value, out MyTestId result) + { + if (string.IsNullOrWhiteSpace(value)) + { + result = default; + return false; + } + result = new MyTestId(value.Trim()); + return true; + } public int CompareTo(MyTestId other) { return (Value, other.Value) switch diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=0.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=0.verified.txt index ff61cdde7..790368aa9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=0.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=0.verified.txt @@ -39,6 +39,18 @@ namespace MyTestNamespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=1.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=1.verified.txt index dacf3158c..574456de9 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=1.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=1.verified.txt @@ -41,6 +41,18 @@ namespace MyTestNamespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=2.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=2.verified.txt index b71458e7e..99d485ef8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=2.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/SourceGenerationHelperSnapshotTests.GeneratesIdWithNestedClassCorrectly_nestedClassCount=2.verified.txt @@ -43,6 +43,18 @@ namespace MyTestNamespace public static bool operator ==(MyTestId a, MyTestId b) => a.Equals(b); public static bool operator !=(MyTestId a, MyTestId b) => !(a == b); + public static MyTestId Parse(string value) => new MyTestId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyTestId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyTestId(parseResult); + return true; + } + result = default; + return false; + } + class MyTestIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter { public override MyTestId Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateDefaultIdInGlobalNamespace.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateDefaultIdInGlobalNamespace.verified.txt index c7c6cb69d..07b4f688b 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateDefaultIdInGlobalNamespace.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateDefaultIdInGlobalNamespace.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -35,6 +35,18 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInFileScopedNamespace.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInFileScopedNamespace.verified.txt index 24d50f9f3..1a971b44e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInFileScopedNamespace.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInFileScopedNamespace.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace SomeNamespace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInNamespace.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInNamespace.verified.txt index 24d50f9f3..1a971b44e 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInNamespace.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdInNamespace.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace SomeNamespace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt index a27c7e82c..eee147955 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt index 3d8d0d003..eff89e606 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=SystemTextJson.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=SystemTextJson.verified.txt index 3bfafc16e..fbd7cbb01 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=SystemTextJson.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=SystemTextJson.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=TypeConverter.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=TypeConverter.verified.txt index 9e21d08b2..141cda10c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=TypeConverter.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=TypeConverter.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=null.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=null.verified.txt index 86f24f872..589b5bea1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=null.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithNamedParameters_backingType=Guid_converter=null.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt index a27c7e82c..eee147955 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson, SystemTextJson.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt index 3d8d0d003..eff89e606 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=NewtonsoftJson.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=SystemTextJson.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=SystemTextJson.verified.txt index 3bfafc16e..fbd7cbb01 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=SystemTextJson.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=SystemTextJson.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdSystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=TypeConverter.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=TypeConverter.verified.txt index 9e21d08b2..141cda10c 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=TypeConverter.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=TypeConverter.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -36,6 +36,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=null.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=null.verified.txt index 86f24f872..589b5bea1 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=null.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateIdWithPositionalParameters_backingType=Guid_converter=null.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace MyTests.TestNameSpace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateMultipleIdsWithSameName.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateMultipleIdsWithSameName.verified.txt index 4ba6d5e1d..83959b92f 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateMultipleIdsWithSameName.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateMultipleIdsWithSameName.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -37,6 +37,18 @@ namespace MyContracts.V1 public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter @@ -141,6 +153,18 @@ namespace MyContracts.V2 public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateNestedIdInFileScopeNamespace.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateNestedIdInFileScopeNamespace.verified.txt index e18df90d1..b2dee4fe8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateNestedIdInFileScopeNamespace.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateNestedIdInFileScopeNamespace.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -39,6 +39,18 @@ namespace SomeNamespace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateVeryNestedIdInFileScopeNamespace.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateVeryNestedIdInFileScopeNamespace.verified.txt index 16880178a..419b1a2d8 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateVeryNestedIdInFileScopeNamespace.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanGenerateVeryNestedIdInFileScopeNamespace.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -43,6 +43,18 @@ namespace SomeNamespace public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(System.Guid.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (System.Guid.TryParse(value, out System.Guid parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); class MyIdTypeConverter : System.ComponentModel.TypeConverter diff --git a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanOverrideDefaultsUsingGlobalAttribute.verified.txt b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanOverrideDefaultsUsingGlobalAttribute.verified.txt index 9b2284cba..c04fa3650 100644 --- a/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanOverrideDefaultsUsingGlobalAttribute.verified.txt +++ b/test/StronglyTypedIds.Tests/Snapshots/StronglyTypedIdGeneratorTests.CanOverrideDefaultsUsingGlobalAttribute.verified.txt @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by the StronglyTypedId source generator // @@ -32,5 +32,17 @@ public override string ToString() => Value.ToString(); public static bool operator ==(MyId a, MyId b) => a.Equals(b); public static bool operator !=(MyId a, MyId b) => !(a == b); + + public static MyId Parse(string value) => new MyId(int.Parse(value)); + public static bool TryParse(string value, out MyId result) + { + if (int.TryParse(value, out int parseResult)) + { + result = new MyId(parseResult); + return true; + } + result = default; + return false; + } public int CompareTo(MyId other) => Value.CompareTo(other.Value); }