diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 81b40fd16..50ebd69aa 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,7 +34,7 @@ jobs: # Test solution # - # Run .NET 8 unit tests + # Run .NET 8 unit tests - script: dotnet test --no-build -c $(Build.Configuration) -f net8.0 -l "trx;LogFileName=VSTestResults_net8.0.trx" displayName: Run .NET 8 unit tests @@ -42,10 +42,6 @@ jobs: - script: dotnet test --no-build -c $(Build.Configuration) -f net7.0 -l "trx;LogFileName=VSTestResults_net7.0.trx" displayName: Run .NET 7 unit tests - # Run .NET 6 unit tests - - script: dotnet test --no-build -c $(Build.Configuration) -f net6.0 -l "trx;LogFileName=VSTestResults_net6.0.trx" - displayName: Run .NET 6 unit tests - # Run .NET Framework 4.7.2 unit tests - script: dotnet test --no-build -c $(Build.Configuration) -f net472 -l "trx;LogFileName=VSTestResults_net472.trx" displayName: Run .NET Framework 4.7.2 unit tests diff --git a/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj b/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj index ddf81b30c..a7d4a430b 100644 --- a/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj +++ b/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net6.0;net8.0 + netstandard2.0;netstandard2.1;net8.0 diff --git a/src/CommunityToolkit.Common/Deferred/EventDeferral.cs b/src/CommunityToolkit.Common/Deferred/EventDeferral.cs index d5a36b7cb..65660ff03 100644 --- a/src/CommunityToolkit.Common/Deferred/EventDeferral.cs +++ b/src/CommunityToolkit.Common/Deferred/EventDeferral.cs @@ -4,6 +4,9 @@ using System; using System.ComponentModel; +#if NET8_0_OR_GREATER +using System.Runtime.CompilerServices; +#endif using System.Threading; using System.Threading.Tasks; @@ -16,8 +19,11 @@ namespace CommunityToolkit.Common.Deferred; /// public class EventDeferral : IDisposable { - // TODO: If/when .NET 6 is base, we can upgrade to non-generic version +#if NET8_0_OR_GREATER + private readonly TaskCompletionSource taskCompletionSource = new(); +#else private readonly TaskCompletionSource taskCompletionSource = new(); +#endif internal EventDeferral() { @@ -26,7 +32,14 @@ internal EventDeferral() /// /// Call when finished with the Deferral. /// - public void Complete() => this.taskCompletionSource.TrySetResult(null); + public void Complete() + { +#if NET8_0_OR_GREATER + this.taskCompletionSource.TrySetResult(); +#else + this.taskCompletionSource.TrySetResult(null); +#endif + } /// /// Waits for the to be completed by the event handler. @@ -38,9 +51,19 @@ internal EventDeferral() [Obsolete("This is an internal only method to be used by EventHandler extension classes, public callers should call GetDeferral() instead on the DeferredEventArgs.")] public async Task WaitForCompletion(CancellationToken cancellationToken) { - using (cancellationToken.Register(() => this.taskCompletionSource.TrySetCanceled())) + using (cancellationToken.Register( +#if NET8_0_OR_GREATER + callback: static obj => Unsafe.As(obj!).taskCompletionSource.TrySetCanceled(), +#else + callback: static obj => ((EventDeferral)obj).taskCompletionSource.TrySetCanceled(), +#endif + state: this)) { +#if NET8_0_OR_GREATER + await this.taskCompletionSource.Task; +#else _ = await this.taskCompletionSource.Task; +#endif } } diff --git a/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj b/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj index fec859625..5f14958a6 100644 --- a/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj +++ b/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net6.0;net8.0 + netstandard2.0;netstandard2.1;net8.0 diff --git a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 2cf7770af..1f17262a5 100644 --- a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0 + netstandard2.0;netstandard2.1;net7.0;net8.0 diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.FeatureSwitches.targets b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.FeatureSwitches.targets index bf6d6ed6c..fefee0e8e 100644 --- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.FeatureSwitches.targets +++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.FeatureSwitches.targets @@ -16,9 +16,9 @@ - + - netstandard2.0;netstandard2.1;net6.0;net8.0;net8.0-windows10.0.17763.0 + netstandard2.0;netstandard2.1;net8.0;net8.0-windows10.0.17763.0 - + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 23f65c476..7239f4a2e 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -7,14 +7,6 @@ NETSTANDARD2_1_OR_GREATER - - - true - true - true - true - - true diff --git a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj index 76bc41862..e47e06627 100644 --- a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj +++ b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj index f3a582df1..633cc0fa4 100644 --- a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj +++ b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj index e49f035d4..772b868c5 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 true $(NoWarn);CA2252 diff --git a/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj index 63a4b907a..5853d5a5c 100644 --- a/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 diff --git a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj index 421cc2315..acb777815 100644 --- a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 diff --git a/tests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests.csproj index c678777f5..eb46db98f 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 true diff --git a/tests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests.csproj index bd5ce9114..b70464cb4 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 true diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests.csproj index 21b341ca9..3656cfdf1 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4001.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests.csproj index 9e59eeb93..495ef1dca 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4031.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 $(DefineConstants);ROSLYN_4_3_1_OR_GREATER diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests.csproj index 83566c52d..a6b432501 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4110.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;net6.0;net7.0;net8.0 + net472;net7.0;net8.0 $(DefineConstants);ROSLYN_4_3_1_OR_GREATER;ROSLYN_4_11_0_OR_GREATER diff --git a/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs b/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs index 6b3e25796..65ab55fe9 100644 --- a/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs +++ b/tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs @@ -709,12 +709,8 @@ public void Test_ObservableProperty_NullabilityAnnotations_Complex() NullabilityInfo rightInfo2 = rightInnerInfo.GenericTypeArguments[2]; Assert.AreEqual(typeof(object), rightInfo2.Type); - //Assert.AreEqual(NullabilityState.NotNull, rightInfo2.ReadState); - //Assert.AreEqual(NullabilityState.NotNull, rightInfo2.WriteState); - - // The commented out lines are to work around a bug in the NullabilityInfo API in .NET 6. - // This has been fixed for .NET 7: https://github.com/dotnet/runtime/pull/63556. The test - // cases above can be uncommented when the .NET 7 target (or a more recent version) is added. + Assert.AreEqual(NullabilityState.NotNull, rightInfo2.ReadState); + Assert.AreEqual(NullabilityState.NotNull, rightInfo2.WriteState); } #endif