diff --git a/Directory.Build.props b/Directory.Build.props
index 091ef215..4c5e4697 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -12,7 +12,7 @@
https://github.com/PawelGerr/Thinktecture.Runtime.Extensions
false
Thinktecture
- net7.0;net8.0
+ net7.0
13.0
true
enable
diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props
index 8830293d..9b43e343 100644
--- a/samples/Directory.Build.props
+++ b/samples/Directory.Build.props
@@ -7,7 +7,7 @@
- net9.0
+ net9.0
$(NoWarn);CS1591;CA1052;CA1062;CA1303;CA1707;CA1801;CA2000;NU1903
false
disable
diff --git a/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore8/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.csproj b/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore8/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.csproj
index c82d49f5..c5af9e96 100644
--- a/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore8/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.csproj
+++ b/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore8/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.csproj
@@ -4,7 +4,7 @@
Extends Entity Framework Core to support some components from Thinktecture.Runtime.Extensions.
common;EntityFrameworkCore
$(DefineConstants);COMPLEX_TYPES
- net8.0
+ net8.0
diff --git a/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore9/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.csproj b/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore9/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.csproj
index f6804548..94c077b6 100644
--- a/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore9/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.csproj
+++ b/src/Thinktecture.Runtime.Extensions.EntityFrameworkCore9/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.csproj
@@ -4,7 +4,7 @@
Extends Entity Framework Core to support some components from Thinktecture.Runtime.Extensions.
common;EntityFrameworkCore
$(DefineConstants);COMPLEX_TYPES
- net8.0
+ net8.0
diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/AdHocUnions/AdHocUnionCodeGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/AdHocUnions/AdHocUnionCodeGenerator.cs
index 5dab5261..6c6f417d 100644
--- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/AdHocUnions/AdHocUnionCodeGenerator.cs
+++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/AdHocUnions/AdHocUnionCodeGenerator.cs
@@ -447,7 +447,17 @@ private void GenerateSwitchForAction(bool withState, bool isPartially)
_sb.Append(" = null");
}
- _sb.Append(@")
+ _sb.Append(")");
+
+ if (withState)
+ {
+ _sb.Append(@"
+#if NET9_0_OR_GREATER
+ where TState : allows ref struct
+#endif");
+ }
+
+ _sb.Append(@"
{");
GenerateIndexBasedActionSwitchBody(withState, isPartially);
@@ -598,6 +608,17 @@ private void GenerateSwitchForFunc(bool withState, bool isPartially)
}
_sb.Append(@")
+#if NET9_0_OR_GREATER
+ where TResult : allows ref struct");
+
+ if (withState)
+ {
+ _sb.Append(@"
+ where TState : allows ref struct");
+ }
+
+ _sb.Append(@"
+#endif
{");
GenerateIndexBasedFuncSwitchBody(withState, isPartially);
@@ -723,6 +744,9 @@ private void GenerateMap(bool isPartially)
}
_sb.Append(@")
+#if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+#endif
{");
GenerateIndexBasedMapSwitchBody(isPartially);
diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs
index 2fbad4f9..437c57ca 100644
--- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs
+++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs
@@ -354,7 +354,17 @@ private void GenerateSwitchForAction(bool withState, bool isPartially)
_sb.Append(" = null");
}
- _sb.Append(@")
+ _sb.Append(")");
+
+ if (withState)
+ {
+ _sb.Append(@"
+#if NET9_0_OR_GREATER
+ where TState : allows ref struct
+#endif");
+ }
+
+ _sb.Append(@"
{");
if (_state.Settings.IsValidatable)
@@ -554,6 +564,17 @@ private void GenerateSwitchForFunc(bool withState, bool isPartially)
}
_sb.Append(@")
+#if NET9_0_OR_GREATER
+ where TResult : allows ref struct");
+
+ if (withState)
+ {
+ _sb.Append(@"
+ where TState : allows ref struct");
+ }
+
+ _sb.Append(@"
+#endif
{");
if (_state.Settings.IsValidatable)
@@ -724,6 +745,9 @@ private void GenerateMap(bool isPartially)
}
_sb.Append(@")
+#if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+#endif
{");
if (_state.Settings.IsValidatable)
diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Unions/UnionCodeGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Unions/UnionCodeGenerator.cs
index c8389ff3..1ef593ca 100644
--- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Unions/UnionCodeGenerator.cs
+++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Unions/UnionCodeGenerator.cs
@@ -250,7 +250,17 @@ private void GenerateSwitchForAction(bool withState, bool isPartially)
_sb.Append(" = null");
}
- _sb.Append(@")
+ _sb.Append(")");
+
+ if (withState)
+ {
+ _sb.Append(@"
+#if NET9_0_OR_GREATER
+ where TState : allows ref struct
+#endif");
+ }
+
+ _sb.Append(@"
{");
GenerateIndexBasedActionSwitchBody(withState, isPartially);
@@ -387,6 +397,17 @@ private void GenerateSwitchForFunc(bool withState, bool isPartially)
}
_sb.Append(@")
+#if NET9_0_OR_GREATER
+ where TResult : allows ref struct");
+
+ if (withState)
+ {
+ _sb.Append(@"
+ where TState : allows ref struct");
+ }
+
+ _sb.Append(@"
+#endif
{");
GenerateIndexBasedFuncSwitchBody(withState, isPartially);
@@ -499,6 +520,9 @@ private void GenerateMap(bool isPartially)
}
_sb.Append(@")
+#if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+#endif
{");
GenerateIndexBasedMapSwitchBody(isPartially);
diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/Thinktecture.Runtime.Extensions.SourceGenerator.csproj b/src/Thinktecture.Runtime.Extensions.SourceGenerator/Thinktecture.Runtime.Extensions.SourceGenerator.csproj
index e04c4d01..eb8d0e28 100644
--- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/Thinktecture.Runtime.Extensions.SourceGenerator.csproj
+++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/Thinktecture.Runtime.Extensions.SourceGenerator.csproj
@@ -1,7 +1,6 @@
Source generators for Thinktecture.Runtime.Extensions.
-
netstandard2.0
sourcegenerator
$(NoWarn);CS1591;RS2008;NU5128
diff --git a/src/Thinktecture.Runtime.Extensions/Argument.cs b/src/Thinktecture.Runtime.Extensions/Argument.cs
index f17730d0..a7077d49 100644
--- a/src/Thinktecture.Runtime.Extensions/Argument.cs
+++ b/src/Thinktecture.Runtime.Extensions/Argument.cs
@@ -5,6 +5,9 @@ namespace Thinktecture;
///
/// The type of the parameter.
public readonly ref struct Argument
+#if NET9_0_OR_GREATER
+ where T : allows ref struct
+#endif
{
///
/// Indication whether the argument is set (explicitly).
diff --git a/src/Thinktecture.Runtime.Extensions/Thinktecture.Runtime.Extensions.csproj b/src/Thinktecture.Runtime.Extensions/Thinktecture.Runtime.Extensions.csproj
index 3242b852..131556ff 100644
--- a/src/Thinktecture.Runtime.Extensions/Thinktecture.Runtime.Extensions.csproj
+++ b/src/Thinktecture.Runtime.Extensions/Thinktecture.Runtime.Extensions.csproj
@@ -3,6 +3,8 @@
Provides an easy way to implement Smart Enums and Value Objects.
smart-enum;value-object;
+
+ net7.0;net9.0;
diff --git a/test/Directory.Build.props b/test/Directory.Build.props
index 079b3763..58a60b15 100644
--- a/test/Directory.Build.props
+++ b/test/Directory.Build.props
@@ -13,6 +13,7 @@
$(NoWarn);CS1591;CA1707;NU1903;NETSDK1206;NU1904
Thinktecture.Runtime.Tests
true
+
net7.0;net8.0;net9.0
diff --git a/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests.csproj b/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests.csproj
index 0837df25..45e09771 100644
--- a/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests.csproj
+++ b/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.Tests.csproj
@@ -2,7 +2,7 @@
$(DefineConstants);COMPLEX_TYPES
- net8.0
+ net8.0;net9.0
diff --git a/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests.csproj b/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests.csproj
index 30d2198e..f7863f78 100644
--- a/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests.csproj
+++ b/test/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.Tests.csproj
@@ -2,7 +2,7 @@
$(DefineConstants);COMPLEX_TYPES
- net8.0
+ net8.0;net9.0
diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.cs
index cfd05252..cdb42f03 100644
--- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.cs
+++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/AdHocUnionSourceGeneratorTests.cs
@@ -133,6 +133,9 @@ public void Switch(
TState state,
global::System.Action @string,
global::System.Action @int32)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -155,6 +158,9 @@ public void Switch(
public TResult Switch(
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -177,6 +183,10 @@ public TResult Switch(
TState state,
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -197,6 +207,9 @@ public TResult Switch(
public TResult Map(
TResult @string,
TResult @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -451,6 +464,9 @@ public void Switch(
TState state,
global::System.Action @string,
global::System.Action @int32)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -476,6 +492,9 @@ public void Switch(
public TResult Switch(
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -501,6 +520,10 @@ public TResult Switch(
TState state,
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -524,6 +547,9 @@ public TResult Switch(
public TResult Map(
TResult @string,
TResult @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -772,6 +798,9 @@ public void Switch(
TState state,
global::System.Action @string,
global::System.Action @int32)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -797,6 +826,9 @@ public void Switch(
public TResult Switch(
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -822,6 +854,10 @@ public TResult Switch(
TState state,
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -845,6 +881,9 @@ public TResult Switch(
public TResult Map(
TResult @string,
TResult @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1088,6 +1127,9 @@ public void Switch(
TState state,
global::System.Action @string,
global::System.Action @int32)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1110,6 +1152,9 @@ public void Switch(
public TResult Switch(
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1132,6 +1177,10 @@ public TResult Switch(
TState state,
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1152,6 +1201,9 @@ public TResult Switch(
public TResult Map(
TResult @string,
TResult @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1379,6 +1431,9 @@ public void Switch(
TState state,
global::System.Action @string,
global::System.Action @int32)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1401,6 +1456,9 @@ public void Switch(
public TResult Switch(
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1423,6 +1481,10 @@ public TResult Switch(
TState state,
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1443,6 +1505,9 @@ public TResult Switch(
public TResult Map(
TResult @string,
TResult @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1722,6 +1787,9 @@ public void Switch(
TState state,
global::System.Action @string,
global::System.Action @int32)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1748,6 +1816,9 @@ public void SwitchPartially(
global::System.Action? @default = null,
global::System.Action? @string = null,
global::System.Action? @int32 = null)
+ #if NET9_0_OR_GREATER
+ where TState : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1778,6 +1849,9 @@ public void SwitchPartially(
public TResult Switch(
global::System.Func @string,
global::System.Func @int32)
+ #if NET9_0_OR_GREATER
+ where TResult : allows ref struct
+ #endif
{
switch (this._valueIndex)
{
@@ -1800,6 +1874,9 @@ public TResult SwitchPartially(
global::System.Func