Skip to content

Commit 2dbb800

Browse files
committed
Removed #if NET7/8 conditionals, now that 8 is the minimum version.
1 parent 5def944 commit 2dbb800

File tree

12 files changed

+3
-98
lines changed

12 files changed

+3
-98
lines changed

DomainModeling.Generator/Configurators/EntityFrameworkConfigurationGenerator.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ private static void GenerateSource(SourceProductionContext context, (Generatable
135135
input.Generatable.ReferencedAssembliesWithDomainEventConfigurator!.Value.Select(assemblyName => $"{assemblyName}.DomainEventDomainModelConfigurator.ConfigureDomainEvents(concreteConfigurator);"));
136136

137137
var source = $@"
138-
#if NET7_0_OR_GREATER
139-
140138
using System;
141139
using System.Diagnostics.CodeAnalysis;
142140
using System.Linq.Expressions;
@@ -401,8 +399,6 @@ public override InstantiationBinding With(IReadOnlyList<ParameterBinding> parame
401399
}}
402400
}}
403401
}}
404-
405-
#endif
406402
";
407403

408404
AddSource(context, source, "EntityFrameworkDomainModelConfigurationExtensions", $"{Constants.DomainModelingNamespace}.EntityFramework");

DomainModeling.Generator/IdentityGenerator.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,10 @@ namespace {containingNamespace}
413413
: {Constants.IdentityInterfaceTypeName}<{underlyingTypeFullyQualifiedName}>,
414414
IEquatable<{idTypeName}>,
415415
IComparable<{idTypeName}>,
416-
#if NET7_0_OR_GREATER
417416
ISpanFormattable,
418417
ISpanParsable<{idTypeName}>,
419-
#endif
420-
#if NET8_0_OR_GREATER
421418
IUtf8SpanFormattable,
422419
IUtf8SpanParsable<{idTypeName}>,
423-
#endif
424420
{Constants.SerializableDomainObjectInterfaceTypeName}<{idTypeName}, {underlyingTypeFullyQualifiedName}>
425421
{{
426422
{(existingComponents.HasFlags(IdTypeComponents.Value) ? "/*" : "")}
@@ -493,7 +489,6 @@ public int CompareTo({idTypeName} other)
493489
{(existingComponents.HasFlags(IdTypeComponents.SerializeToUnderlying) ? "*/" : "")}
494490
495491
{(existingComponents.HasFlags(IdTypeComponents.DeserializeFromUnderlying) ? "/*" : "")}
496-
#if NET7_0_OR_GREATER
497492
/// <summary>
498493
/// Deserializes a plain value back into a domain object, without any validation.
499494
/// </summary>
@@ -503,7 +498,6 @@ public int CompareTo({idTypeName} other)
503498
{(existingComponents.HasFlag(IdTypeComponents.UnsettableValue) ? $"return System.Runtime.CompilerServices.Unsafe.As<{underlyingTypeFullyQualifiedName}, {idTypeName}>(ref value);" : "")}
504499
{(existingComponents.HasFlag(IdTypeComponents.UnsettableValue) ? "//" : "")}return new {idTypeName}() {{ Value = value }};
505500
}}
506-
#endif
507501
{(existingComponents.HasFlags(IdTypeComponents.DeserializeFromUnderlying) ? "*/" : "")}
508502
509503
{(existingComponents.HasFlags(IdTypeComponents.EqualsOperator) ? "/*" : "")}
@@ -546,8 +540,6 @@ public int CompareTo({idTypeName} other)
546540
547541
#region Formatting & Parsing
548542
549-
#if NET7_0_OR_GREATER
550-
551543
{(existingComponents.HasFlags(IdTypeComponents.FormattableToStringOverride) ? "/*" : "")}
552544
public string ToString(string? format, IFormatProvider? formatProvider) =>
553545
FormattingHelper.ToString(this.Value, format, formatProvider);
@@ -582,10 +574,6 @@ public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [Ma
582574
({idTypeName})ParsingHelper.Parse<{underlyingTypeFullyQualifiedName}>(s, provider);
583575
{(existingComponents.HasFlags(IdTypeComponents.SpanParsableParseMethod) ? "*/" : "")}
584576
585-
#endif
586-
587-
#if NET8_0_OR_GREATER
588-
589577
{(existingComponents.HasFlags(IdTypeComponents.Utf8SpanFormattableTryFormatMethod) ? "/*" : "")}
590578
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider) =>
591579
FormattingHelper.TryFormat(this.Value, utf8Destination, out bytesWritten, format, provider);
@@ -603,8 +591,6 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
603591
({idTypeName})ParsingHelper.Parse<{underlyingTypeFullyQualifiedName}>(utf8Text, provider);
604592
{(existingComponents.HasFlags(IdTypeComponents.Utf8SpanParsableParseMethod) ? "*/" : "")}
605593
606-
#endif
607-
608594
#endregion
609595
}}
610596
}}

DomainModeling.Generator/WrapperValueObjectGenerator.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,10 @@ namespace {containingNamespace}
348348
: {Constants.WrapperValueObjectTypeName}<{underlyingTypeFullyQualifiedName}>,
349349
IEquatable<{typeName}>,
350350
{(isComparable ? "" : "/*")}IComparable<{typeName}>,{(isComparable ? "" : "*/")}
351-
#if NET7_0_OR_GREATER
352351
ISpanFormattable,
353352
ISpanParsable<{typeName}>,
354-
#endif
355-
#if NET8_0_OR_GREATER
356353
IUtf8SpanFormattable,
357354
IUtf8SpanParsable<{typeName}>,
358-
#endif
359355
{Constants.SerializableDomainObjectInterfaceTypeName}<{typeName}, {underlyingTypeFullyQualifiedName}>
360356
{{
361357
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.StringComparison) ? "/*" : "")}
@@ -439,30 +435,21 @@ public int CompareTo({typeName}? other)
439435
440436
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.DeserializeFromUnderlying) ? "/*" : "")}
441437
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.UnsettableValue) ? $@"
442-
#if NET8_0_OR_GREATER
443438
[System.Runtime.CompilerServices.UnsafeAccessor(System.Runtime.CompilerServices.UnsafeAccessorKind.Field, Name = ""{valueFieldName}"")]
444-
private static extern ref {underlyingTypeFullyQualifiedName} GetValueFieldReference({typeName} instance);
445-
#elif NET7_0_OR_GREATER
446-
private static readonly System.Reflection.FieldInfo ValueFieldInfo = typeof({typeName}).GetField(""{valueFieldName}"", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic)!;
447-
#endif" : "")}
448-
#if NET7_0_OR_GREATER
439+
private static extern ref {underlyingTypeFullyQualifiedName} GetValueFieldReference({typeName} instance);" : "")}
440+
449441
/// <summary>
450442
/// Deserializes a plain value back into a domain object, without any validation.
451443
/// </summary>
452444
static {typeName} {Constants.SerializableDomainObjectInterfaceTypeName}<{typeName}, {underlyingTypeFullyQualifiedName}>.Deserialize({underlyingTypeFullyQualifiedName} value)
453445
{{
454446
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.UnsettableValue) ? $@"
455447
// To instead get syntax that is safe at compile time, make the Value property '{{ get; private init; }}' (or let the source generator implement it)
456-
#if NET8_0_OR_GREATER
457-
var result = new {typeName}(); GetValueFieldReference(result) = value; return result;
458-
#else
459-
var result = new {typeName}(); ValueFieldInfo.SetValue(result, value); return result;
460-
#endif" : "")}
448+
var result = new {typeName}(); GetValueFieldReference(result) = value; return result;" : "")}
461449
#pragma warning disable CS0618 // Obsolete constructor is intended for us
462450
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.UnsettableValue) ? "//" : "")}return new {typeName}() {{ Value = value }};
463451
#pragma warning restore CS0618
464452
}}
465-
#endif
466453
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.DeserializeFromUnderlying) ? "*/" : "")}
467454
468455
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.EqualsOperator) ? "/*" : "")}
@@ -509,8 +496,6 @@ public int CompareTo({typeName}? other)
509496
510497
#region Formatting & Parsing
511498
512-
#if NET7_0_OR_GREATER
513-
514499
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.FormattableToStringOverride) ? "/*" : "")}
515500
public string ToString(string? format, IFormatProvider? formatProvider) =>
516501
FormattingHelper.ToString(this.Value, format, formatProvider);
@@ -545,10 +530,6 @@ public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [Ma
545530
({typeName})ParsingHelper.Parse<{underlyingTypeFullyQualifiedName}>(s, provider);
546531
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.SpanParsableParseMethod) ? "*/" : "")}
547532
548-
#endif
549-
550-
#if NET8_0_OR_GREATER
551-
552533
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.Utf8SpanFormattableTryFormatMethod) ? "/*" : "")}
553534
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider) =>
554535
FormattingHelper.TryFormat(this.Value, utf8Destination, out bytesWritten, format, provider);
@@ -566,8 +547,6 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
566547
({typeName})ParsingHelper.Parse<{underlyingTypeFullyQualifiedName}>(utf8Text, provider);
567548
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.Utf8SpanParsableParseMethod) ? "*/" : "")}
568549
569-
#endif
570-
571550
#endregion
572551
}}
573552
}}

DomainModeling.Tests/IdentityTests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -754,14 +754,10 @@ internal readonly partial struct FullySelfImplementedIdentity
754754
: IIdentity<int>,
755755
IEquatable<FullySelfImplementedIdentity>,
756756
IComparable<FullySelfImplementedIdentity>,
757-
#if NET7_0_OR_GREATER
758757
ISpanFormattable,
759758
ISpanParsable<FullySelfImplementedIdentity>,
760-
#endif
761-
#if NET8_0_OR_GREATER
762759
IUtf8SpanFormattable,
763760
IUtf8SpanParsable<FullySelfImplementedIdentity>,
764-
#endif
765761
ISerializableDomainObject<FullySelfImplementedIdentity, int>
766762
{
767763
public int Value { get; private init; }
@@ -830,8 +826,6 @@ static FullySelfImplementedIdentity ISerializableDomainObject<FullySelfImplement
830826

831827
#region Formatting & Parsing
832828

833-
#if NET7_0_OR_GREATER
834-
835829
public string ToString(string? format, IFormatProvider? formatProvider) =>
836830
FormattingHelper.ToString(this.Value, format, formatProvider);
837831

@@ -854,10 +848,6 @@ public static FullySelfImplementedIdentity Parse(string s, IFormatProvider? prov
854848
public static FullySelfImplementedIdentity Parse(ReadOnlySpan<char> s, IFormatProvider? provider) =>
855849
(FullySelfImplementedIdentity)ParsingHelper.Parse<int>(s, provider);
856850

857-
#endif
858-
859-
#if NET8_0_OR_GREATER
860-
861851
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider) =>
862852
FormattingHelper.TryFormat(this.Value, utf8Destination, out bytesWritten, format, provider);
863853

@@ -869,8 +859,6 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
869859
public static FullySelfImplementedIdentity Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) =>
870860
(FullySelfImplementedIdentity)ParsingHelper.Parse<int>(utf8Text, provider);
871861

872-
#endif
873-
874862
#endregion
875863
}
876864
}

DomainModeling.Tests/WrapperValueObjectTests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -778,14 +778,10 @@ public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnly
778778
internal sealed partial class FullySelfImplementedWrapperValueObject
779779
: WrapperValueObject<int>,
780780
IComparable<FullySelfImplementedWrapperValueObject>,
781-
#if NET7_0_OR_GREATER
782781
ISpanFormattable,
783782
ISpanParsable<FullySelfImplementedWrapperValueObject>,
784-
#endif
785-
#if NET8_0_OR_GREATER
786783
IUtf8SpanFormattable,
787784
IUtf8SpanParsable<FullySelfImplementedWrapperValueObject>,
788-
#endif
789785
ISerializableDomainObject<FullySelfImplementedWrapperValueObject, int>
790786
{
791787
protected sealed override StringComparison StringComparison => throw new NotSupportedException("This operation applies to string-based value objects only.");
@@ -865,8 +861,6 @@ static FullySelfImplementedWrapperValueObject ISerializableDomainObject<FullySel
865861

866862
#region Formatting & Parsing
867863

868-
#if NET7_0_OR_GREATER
869-
870864
public string ToString(string? format, IFormatProvider? formatProvider) =>
871865
FormattingHelper.ToString(this.Value, format, formatProvider);
872866

@@ -889,10 +883,6 @@ public static FullySelfImplementedWrapperValueObject Parse(string s, IFormatProv
889883
public static FullySelfImplementedWrapperValueObject Parse(ReadOnlySpan<char> s, IFormatProvider? provider) =>
890884
(FullySelfImplementedWrapperValueObject)ParsingHelper.Parse<int>(s, provider);
891885

892-
#endif
893-
894-
#if NET8_0_OR_GREATER
895-
896886
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider) =>
897887
FormattingHelper.TryFormat(this.Value, utf8Destination, out bytesWritten, format, provider);
898888

@@ -904,8 +894,6 @@ public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provid
904894
public static FullySelfImplementedWrapperValueObject Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) =>
905895
(FullySelfImplementedWrapperValueObject)ParsingHelper.Parse<int>(utf8Text, provider);
906896

907-
#endif
908-
909897
#endregion
910898
}
911899
}

DomainModeling/Conversions/DomainObjectSerializer.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#if NET7_0_OR_GREATER
2-
31
using System.Diagnostics.CodeAnalysis;
42
using System.Linq.Expressions;
53
using System.Reflection;
@@ -196,5 +194,3 @@ private static MethodCallExpression CreateSerializeExpressionCore([DynamicallyAc
196194

197195
#endregion
198196
}
199-
200-
#endif

DomainModeling/Conversions/FormattingExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace Architect.DomainModeling.Conversions;
55
/// </summary>
66
public static class FormattingExtensions
77
{
8-
#if NET7_0_OR_GREATER
98
/// <summary>
109
/// <para>
1110
/// Formats the <paramref name="value"/> into the provided <paramref name="buffer"/>, returning the segment that was written to.
@@ -26,5 +25,4 @@ public static ReadOnlySpan<char> Format<T>(this T value, Span<char> buffer, Read
2625

2726
return buffer[..charCount];
2827
}
29-
#endif
3028
}

DomainModeling/Conversions/FormattingHelper.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace Architect.DomainModeling.Conversions;
1515
/// </summary>
1616
public static class FormattingHelper
1717
{
18-
#if NET7_0_OR_GREATER
19-
2018
/// <summary>
2119
/// This overload throws because <see cref="IFormattable"/> is unavailable.
2220
/// Implement the interface to have overload resolution pick the functional overload.
@@ -117,10 +115,6 @@ public static bool TryFormat(string? instance,
117115
}
118116
#pragma warning restore IDE0060 // Remove unused parameter
119117

120-
#endif
121-
122-
#if NET8_0_OR_GREATER
123-
124118
/// <summary>
125119
/// This overload throws because <see cref="IUtf8SpanFormattable"/> is unavailable.
126120
/// Implement the interface to have overload resolution pick the functional overload.
@@ -172,6 +166,4 @@ public static bool TryFormat(string instance,
172166
return Utf8.FromUtf16(instance, utf8Destination, charsRead: out _, bytesWritten: out bytesWritten) == System.Buffers.OperationStatus.Done;
173167
}
174168
#pragma warning restore IDE0060 // Remove unused parameter
175-
176-
#endif
177169
}

DomainModeling/Conversions/ObjectInstantiator.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ static ObjectInstantiator()
2727
}
2828
else if (typeof(T).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, binder: null, Array.Empty<Type>(), modifiers: null) is ConstructorInfo ctor)
2929
{
30-
#if NET8_0_OR_GREATER
3130
var invoker = ConstructorInvoker.Create(ctor);
3231
ConstructionFunction = () => (T)invoker.Invoke();
33-
#else
34-
ConstructionFunction = () => (T)Activator.CreateInstance(typeof(T), nonPublic: true)!;
35-
#endif
3632
}
3733
else
3834
{

DomainModeling/Conversions/ParsingHelper.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace Architect.DomainModeling.Conversions;
1616
/// </summary>
1717
public static class ParsingHelper
1818
{
19-
#if NET7_0_OR_GREATER
20-
2119
/// <summary>
2220
/// This overload throws because <see cref="IParsable{TSelf}"/> is unavailable.
2321
/// Implement the interface to have overload resolution pick the functional overload.
@@ -98,10 +96,6 @@ public static T Parse<T>(ReadOnlySpan<char> s, IFormatProvider? provider)
9896
return T.Parse(s, provider);
9997
}
10098

101-
#endif
102-
103-
#if NET8_0_OR_GREATER
104-
10599
#pragma warning disable IDE0060 // Remove unused parameter -- Required to let generated code make use of overload resolution
106100
/// <summary>
107101
/// <para>
@@ -170,6 +164,4 @@ public static T Parse<T>(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
170164
{
171165
return T.Parse(utf8Text, provider);
172166
}
173-
174-
#endif
175167
}

0 commit comments

Comments
 (0)