Skip to content

Commit fbae1cf

Browse files
committed
Added .NET 10 and fixed an issue with the new parsing/formatting extension members.
1 parent 0564c88 commit fbae1cf

16 files changed

+108
-42
lines changed

DomainModeling.Example/DomainModeling.Example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<AssemblyName>Architect.DomainModeling.Example</AssemblyName>
77
<RootNamespace>Architect.DomainModeling.Example</RootNamespace>
88
<Nullable>Enable</Nullable>
99
<ImplicitUsings>Enable</ImplicitUsings>
1010
<IsPackable>False</IsPackable>
1111
<IsTrimmable>True</IsTrimmable>
12-
<LangVersion>13</LangVersion>
12+
<LangVersion>14</LangVersion>
1313
</PropertyGroup>
1414

1515
<PropertyGroup>

DomainModeling.Generator/DomainModeling.Generator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<RootNamespace>Architect.DomainModeling.Generator</RootNamespace>
77
<Nullable>Enable</Nullable>
88
<ImplicitUsings>Enable</ImplicitUsings>
9-
<LangVersion>13</LangVersion>
9+
<LangVersion>14</LangVersion>
1010
<IsPackable>False</IsPackable>
1111
<DevelopmentDependency>True</DevelopmentDependency>
1212
<EnforceExtendedAnalyzerRules>True</EnforceExtendedAnalyzerRules>

DomainModeling.Generator/IdentityGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ public int CompareTo({idTypeName} other)
745745
746746
#region Formatting & Parsing
747747
748-
//#if !NET10_0_OR_GREATER // Starting with .NET 10, these operations are provided by default implementations and extension methods
748+
#if !NET10_0_OR_GREATER // Starting with .NET 10, these operations are provided by default implementations and extension methods
749749
750750
{(!isSpanFormattable || existingComponents.HasFlags(IdTypeComponents.FormattableToStringOverride) ? "/*" : "")}
751751
public string ToString(string? format, IFormatProvider? formatProvider) =>
@@ -798,7 +798,7 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
798798
({idTypeName})ParsingHelper.Parse<{underlyingTypeFullyQualifiedName}>(utf8Text, provider);
799799
{(!isUtf8SpanParsable || existingComponents.HasFlags(IdTypeComponents.Utf8SpanParsableParseMethod) ? "*/" : "")}
800800
801-
//#endif
801+
#endif
802802
803803
#endregion
804804
}}

DomainModeling.Generator/WrapperValueObjectGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public int CompareTo({typeName}{(generatable.IsClass ? "?" : "")} other)
671671
672672
#region Formatting & Parsing
673673
674-
//#if !NET10_0_OR_GREATER // Starting with .NET 10, these operations are provided by default implementations and extension methods
674+
#if !NET10_0_OR_GREATER // Starting with .NET 10, these operations are provided by default implementations and extension methods
675675
676676
{(!isSpanFormattable || existingComponents.HasFlags(WrapperValueObjectTypeComponents.FormattableToStringOverride) ? "/*" : "")}
677677
public string ToString(string? format, IFormatProvider? formatProvider) =>
@@ -724,7 +724,7 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
724724
({typeName})ParsingHelper.Parse<{underlyingTypeFullyQualifiedName}>(utf8Text, provider);
725725
{(!isUtf8SpanParsable || existingComponents.HasFlags(WrapperValueObjectTypeComponents.Utf8SpanParsableParseMethod) ? "*/" : "")}
726726
727-
//#endif
727+
#endif
728728
729729
#endregion
730730
}}

DomainModeling.Tests/DomainModeling.Tests.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
55
<AssemblyName>Architect.DomainModeling.Tests</AssemblyName>
66
<RootNamespace>Architect.DomainModeling.Tests</RootNamespace>
77
<Nullable>Enable</Nullable>
88
<ImplicitUsings>Enable</ImplicitUsings>
9-
<LangVersion>13</LangVersion>
9+
<LangVersion>14</LangVersion>
1010
<IsPackable>False</IsPackable>
1111
</PropertyGroup>
1212

DomainModeling.Tests/IdentityTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ static FullySelfImplementedIdentity IValueWrapper<FullySelfImplementedIdentity,
10901090

10911091
#region Formatting & Parsing
10921092

1093-
//#if !NET10_0_OR_GREATER // Starting from .NET 10, these operations are provided by default implementations and extension methods
1093+
#if !NET10_0_OR_GREATER // Starting from .NET 10, these operations are provided by default implementations and extension methods
10941094

10951095
public string ToString(string? format, IFormatProvider? formatProvider) =>
10961096
FormattingHelper.ToString(this.Value, format, formatProvider);
@@ -1125,7 +1125,7 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
11251125
public static FullySelfImplementedIdentity Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) =>
11261126
(FullySelfImplementedIdentity)ParsingHelper.Parse<int>(utf8Text, provider);
11271127

1128-
//#endif
1128+
#endif
11291129

11301130
#endregion
11311131
}

DomainModeling.Tests/WrapperValueObjectTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ static FullySelfImplementedWrapperValueObject IValueWrapper<FullySelfImplemented
11641164

11651165
#region Formatting & Parsing
11661166

1167-
//#if !NET10_0_OR_GREATER // Starting from .NET 10, these operations are provided by default implementations and extension methods
1167+
#if !NET10_0_OR_GREATER // Starting from .NET 10, these operations are provided by default implementations and extension methods
11681168

11691169
public string ToString(string? format, IFormatProvider? formatProvider) =>
11701170
FormattingHelper.ToString(this.Value, format, formatProvider);
@@ -1199,7 +1199,7 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
11991199
public static FullySelfImplementedWrapperValueObject Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) =>
12001200
(FullySelfImplementedWrapperValueObject)ParsingHelper.Parse<int>(utf8Text, provider);
12011201

1202-
//#endif
1202+
#endif
12031203

12041204
#endregion
12051205
}

DomainModeling/Conversions/ValueWrapperFormattingExtensions.cs renamed to DomainModeling/Conversions/DirectValueWrapperFormattingExtensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/// <summary>
1111
/// <para>
12-
/// Provides formatting methods on types marked with <see cref="IValueWrapper{TWrapper, TValue}"/>.
12+
/// Provides formatting methods on types marked with <see cref="IDirectValueWrapper{TWrapper, TValue}"/>.
1313
/// </para>
1414
/// <para>
1515
/// <see cref="IFormattableWrapper{TWrapper, TValue}"/> &amp; co provide default interface implementations that alleviate the need to implement formatting methods manually for value wrappers.
@@ -22,10 +22,10 @@
2222
#pragma warning disable IDE0079 // Remove unnecessary suppression -- Suppression below is falsely flagged as unnecessary
2323
#pragma warning disable CA1050 // Declare types in namespaces -- Lives in global namespace for visibility of extensions, on highly specific types
2424
[EditorBrowsable(EditorBrowsableState.Never)]
25-
public static class ArchitectDomainModelingValueWrapperFormattingExtensions
25+
public static class ArchitectDomainModelingDirectValueWrapperFormattingExtensions
2626
{
27-
extension<TWrapper, TValue>(IValueWrapper<TWrapper, TValue> wrapper)
28-
where TWrapper : IFormattable, IValueWrapper<TWrapper, TValue>
27+
extension<TWrapper, TValue>(IDirectValueWrapper<TWrapper, TValue> wrapper)
28+
where TWrapper : IFormattable, IDirectValueWrapper<TWrapper, TValue>
2929
{
3030
/// <summary>
3131
/// Beware: <see cref="IFormattable"/>.<see cref="IFormattable.ToString"/> promises a non-null result, but not all cases can correctly fulfill that promise.
@@ -38,8 +38,8 @@ public string ToString(string? format, IFormatProvider? formatProvider)
3838
}
3939
}
4040

41-
extension<TWrapper, TValue>(IValueWrapper<TWrapper, TValue> wrapper)
42-
where TWrapper : ISpanFormattable, IValueWrapper<TWrapper, TValue>
41+
extension<TWrapper, TValue>(IDirectValueWrapper<TWrapper, TValue> wrapper)
42+
where TWrapper : ISpanFormattable, IDirectValueWrapper<TWrapper, TValue>
4343
{
4444
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4545
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
@@ -48,8 +48,8 @@ public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan
4848
}
4949
}
5050

51-
extension<TWrapper, TValue>(IValueWrapper<TWrapper, TValue> wrapper)
52-
where TWrapper : IUtf8SpanFormattable, IValueWrapper<TWrapper, TValue>
51+
extension<TWrapper, TValue>(IDirectValueWrapper<TWrapper, TValue> wrapper)
52+
where TWrapper : IUtf8SpanFormattable, IDirectValueWrapper<TWrapper, TValue>
5353
{
5454
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5555
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)

DomainModeling/Conversions/ValueWrapperParsingExtensions.cs renamed to DomainModeling/Conversions/DirectValueWrapperParsingExtensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/// <summary>
1010
/// <para>
11-
/// Provides parsing methods on types marked with <see cref="IValueWrapper{TWrapper, TValue}"/>.
11+
/// Provides parsing methods on types marked with <see cref="IDirectValueWrapper{TWrapper, TValue}"/>.
1212
/// </para>
1313
/// <para>
1414
/// <see cref="IParsableWrapper{TWrapper, TValue}"/> &amp; co provide default interface implementations that alleviate the need to implement parse methods manually for value wrappers.
@@ -21,10 +21,10 @@
2121
#pragma warning disable IDE0079 // Remove unnecessary suppression -- Suppression below is falsely flagged as unnecessary
2222
#pragma warning disable CA1050 // Declare types in namespaces -- Lives in global namespace for visibility of extensions, on highly specific types
2323
[EditorBrowsable(EditorBrowsableState.Never)]
24-
public static class ArchitectDomainModelingValueWrapperParsingExtensions
24+
public static class ArchitectDomainModelingDirectValueWrapperParsingExtensions
2525
{
26-
extension<TWrapper, TValue>(IValueWrapper<TWrapper, TValue> wrapper)
27-
where TWrapper : IParsable<TWrapper>, IValueWrapper<TWrapper, TValue>
26+
extension<TWrapper, TValue>(IDirectValueWrapper<TWrapper, TValue> wrapper)
27+
where TWrapper : IParsable<TWrapper>, IDirectValueWrapper<TWrapper, TValue>
2828
{
2929
[OverloadResolutionPriority(-1)]
3030
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -41,8 +41,8 @@ public static TWrapper Parse(string s, IFormatProvider? provider)
4141
}
4242
}
4343

44-
extension<TWrapper, TValue>(IValueWrapper<TWrapper, TValue> wrapper)
45-
where TWrapper : ISpanParsable<TWrapper>, IValueWrapper<TWrapper, TValue>
44+
extension<TWrapper, TValue>(IDirectValueWrapper<TWrapper, TValue> wrapper)
45+
where TWrapper : ISpanParsable<TWrapper>, IDirectValueWrapper<TWrapper, TValue>
4646
{
4747
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4848
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [MaybeNullWhen(false)] out TWrapper result)
@@ -57,8 +57,8 @@ public static TWrapper Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
5757
}
5858
}
5959

60-
extension<TWrapper, TValue>(IValueWrapper<TWrapper, TValue> wrapper)
61-
where TWrapper : IUtf8SpanParsable<TWrapper>, IValueWrapper<TWrapper, TValue>
60+
extension<TWrapper, TValue>(IDirectValueWrapper<TWrapper, TValue> wrapper)
61+
where TWrapper : IUtf8SpanParsable<TWrapper>, IDirectValueWrapper<TWrapper, TValue>
6262
{
6363
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6464
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out TWrapper result)

DomainModeling/Conversions/FormattingHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace Architect.DomainModeling.Conversions;
1313
/// This type is intended for use by source-generated code, to avoid compiler errors in situations where the presence of the required interfaces is extremely likely but cannot be guaranteed.
1414
/// </para>
1515
/// </summary>
16-
//#if NET10_0_OR_GREATER
17-
//[Obsolete("New default interface implementations and extension members alleviate the need for this helper.")]
18-
//#endif
16+
#if NET10_0_OR_GREATER
17+
[Obsolete("New default interface implementations and extension members alleviate the need for this helper.")]
18+
#endif
1919
public static class FormattingHelper
2020
{
2121
/// <summary>

0 commit comments

Comments
 (0)