Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ 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

# Run .NET 7 unit tests
- 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
Expand Down
2 changes: 1 addition & 1 deletion src/CommunityToolkit.Common/CommunityToolkit.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
29 changes: 26 additions & 3 deletions src/CommunityToolkit.Common/Deferred/EventDeferral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -16,8 +19,11 @@ namespace CommunityToolkit.Common.Deferred;
/// </summary>
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<object?> taskCompletionSource = new();
#endif

internal EventDeferral()
{
Expand All @@ -26,7 +32,14 @@ internal EventDeferral()
/// <summary>
/// Call when finished with the Deferral.
/// </summary>
public void Complete() => this.taskCompletionSource.TrySetResult(null);
public void Complete()
{
#if NET8_0_OR_GREATER
this.taskCompletionSource.TrySetResult();
#else
this.taskCompletionSource.TrySetResult(null);
#endif
}

/// <summary>
/// Waits for the <see cref="EventDeferral"/> to be completed by the event handler.
Expand All @@ -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<EventDeferral>(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
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<!--
Configuration for the feature switches (to support IL trimming).
See the 'ILLink.Substitutions.xml' file for more details on that.
We only include these on .NET 6 and above (no .xml file otherwise).
We only include these on .NET 8 and above (no .xml file otherwise).
-->
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">

<!-- MVVMTOOLKIT_ENABLE_INOTIFYPROPERTYCHANGING_SUPPORT switch -->
<RuntimeHostConfigurationOption Include="MVVMTOOLKIT_ENABLE_INOTIFYPROPERTYCHANGING_SUPPORT"
Expand Down
4 changes: 2 additions & 2 deletions src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0;net8.0-windows10.0.17763.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net8.0-windows10.0.17763.0</TargetFrameworks>
</PropertyGroup>

<!--
Expand Down Expand Up @@ -55,7 +55,7 @@
</ItemGroup>

<!-- Include the ILLink file (to properly trim configuration switches in publish builds) -->
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<EmbeddedResource Include="Properties\ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
</ItemGroup>

Expand Down
8 changes: 0 additions & 8 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>

<!-- Configure trimming for projects on .NET 6 and above -->
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsTrimmable>true</IsTrimmable>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
</PropertyGroup>

<!-- Set the AOT property directly on .NET 8 and above -->
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<NoWarn>$(NoWarn);CA2252</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);ROSLYN_4_3_1_OR_GREATER</DefineConstants>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net7.0;net8.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);ROSLYN_4_3_1_OR_GREATER;ROSLYN_4_11_0_OR_GREATER</DefineConstants>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down