diff --git a/Directory.Build.props b/Directory.Build.props index 6510902b7..8f47496d2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -25,7 +25,7 @@ - + diff --git a/global.json b/global.json index 00b67caef..7a2ec8f6d 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100", + "version": "9.0.102", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/src/CommunityToolkit.HighPerformance/Buffers/StringPool.cs b/src/CommunityToolkit.HighPerformance/Buffers/StringPool.cs index b1ef81e37..abe3aeb27 100644 --- a/src/CommunityToolkit.HighPerformance/Buffers/StringPool.cs +++ b/src/CommunityToolkit.HighPerformance/Buffers/StringPool.cs @@ -376,7 +376,7 @@ public FixedSizePriorityMap(int capacity) /// /// Gets an that can be used to synchronize access to the current instance. /// - public object SyncRoot + public readonly object SyncRoot { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => this.buckets; @@ -749,7 +749,7 @@ private void UpdateTimestamp(ref int heapIndex) /// a given number of nodes, those are all contiguous from the start of the array. /// [MethodImpl(MethodImplOptions.NoInlining)] - private void UpdateAllTimestamps() + private readonly void UpdateAllTimestamps() { int count = this.count; ref HeapEntry heapEntriesRef = ref this.heapEntries.DangerousGetReference(); diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs index 0548c4467..354c17fe6 100644 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs +++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs @@ -134,7 +134,7 @@ private void Add(int value) /// Gets the resulting hashcode from the current instance. /// /// The resulting hashcode from the current instance. - public int ToHashCode() + public readonly int ToHashCode() { uint length = this.length; uint position = length % 4; @@ -165,12 +165,12 @@ public int ToHashCode() /// [Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes. Use ToHashCode to retrieve the computed hash code.", error: true)] [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => throw new NotSupportedException(); + public override readonly int GetHashCode() => throw new NotSupportedException(); /// [Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes.", error: true)] [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object? obj) => throw new NotSupportedException(); + public override readonly bool Equals(object? obj) => throw new NotSupportedException(); /// /// Rotates the specified value left by the specified number of bits. diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.WindowsSdk.targets b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.WindowsSdk.targets index cf89f2def..f51332a68 100644 --- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.WindowsSdk.targets +++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.WindowsSdk.targets @@ -27,9 +27,9 @@ - The recommended Windows SDK package for UWP projects using the .NET 9 SDK (with UWP XAML projections). - The recommended Windows SDK package for WindowsAppSDK projects (ie. without UWP XAML projections). --> - <_MvvmToolkitWindowsSdkPackageMinBuild>38 - <_MvvmToolkitWindowsSdkPackageRecommendedUwpBuild>54 - <_MvvmToolkitWindowsSdkPackageRecommendedWindowsAppSDKBuild>53 + <_MvvmToolkitWindowsSdkPackageMinBuild>56 + <_MvvmToolkitWindowsSdkPackageRecommendedUwpBuild>57 + <_MvvmToolkitWindowsSdkPackageRecommendedWindowsAppSDKBuild>56 <_MvvmToolkitWindowsSdkPackageRecommendedBuild>$(_MvvmToolkitWindowsSdkPackageMinBuild) @@ -82,7 +82,7 @@ Condition="'@(_MvvmToolkitCompatibleWindowsSdkPackages)' == ''" Code="MVVMTKCFG0003" HelpLink="https://aka.ms/mvvmtoolkit/errors/mvvmtkcfg0003" - Text="This version of the MVVM Toolkit requires 'Microsoft.Windows.SDK.NET.Ref' version '$(_MvvmToolkitWindowsSdkPackageRequired)' or later. Please update to .NET SDK 8.0.109, 8.0.305 or 8.0.402 (or later). Alternatively, use a temporary 'Microsoft.Windows.SDK.NET.Ref' reference, which can be done by setting the 'WindowsSdkPackageVersion' property in your .csproj file. For your project configuration, it is recommended to set the package version to '$(_MvvmToolkitWindowsSdkPackageRecommended)'." /> + Text="This version of the MVVM Toolkit requires 'Microsoft.Windows.SDK.NET.Ref' version '$(_MvvmToolkitWindowsSdkPackageRequired)' or later. Please update the .NET SDK in use to 8.0.405 (or later) or 9.0.102 (or later). Alternatively, use a temporary 'Microsoft.Windows.SDK.NET.Ref' reference, which can be done by setting the 'WindowsSdkPackageVersion' property in your .csproj file. For your project configuration, it is recommended to set the package version to '$(_MvvmToolkitWindowsSdkPackageRecommended)'." /> \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj index dd7c98d01..8b535df49 100644 --- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj +++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj @@ -9,7 +9,7 @@ because we need the source generators in CsWinRT to generate the supporting interop code for AOT). --> - 10.0.17763.53 + 10.0.17763.56 - + @@ -61,7 +61,7 @@ - + diff --git a/src/CommunityToolkit.Mvvm/Messaging/IMessengerExtensions.Observables.cs b/src/CommunityToolkit.Mvvm/Messaging/IMessengerExtensions.Observables.cs index 4675a3193..b930203ab 100644 --- a/src/CommunityToolkit.Mvvm/Messaging/IMessengerExtensions.Observables.cs +++ b/src/CommunityToolkit.Mvvm/Messaging/IMessengerExtensions.Observables.cs @@ -3,14 +3,9 @@ // See the LICENSE file in the project root for more information. using System; - -// This file has two types which implement interfaces that can be projected to WInRT, ie. -// 'Observable.Recipient' and 'Observable.Recipient', which -// implement 'IDisposable' (which is projected to 'IClosable'). These types are not meant -// to be used in interop scenarios (including in eg. bindings), as they're only meant to -// be used by code behind interacting with System.Reactive APIs. As such, we skip marking -// them partial, as we don't need CCW vtables to be generated for them. -#pragma warning disable CsWinRT1028 +#if NET8_0_OR_GREATER && WINDOWS +using WinRT; +#endif namespace CommunityToolkit.Mvvm.Messaging; @@ -81,6 +76,9 @@ public IDisposable Subscribe(IObserver observer) /// /// An implementation for . /// +#if NET8_0_OR_GREATER && WINDOWS + [WinRTExposedType(typeof(WinRTManagedOnlyTypeDetails))] +#endif private sealed class Recipient : IRecipient, IDisposable { /// @@ -159,6 +157,9 @@ public IDisposable Subscribe(IObserver observer) /// /// An implementation for . /// +#if NET8_0_OR_GREATER && WINDOWS + [WinRTExposedType(typeof(WinRTManagedOnlyTypeDetails))] +#endif private sealed class Recipient : IRecipient, IDisposable { /// diff --git a/src/CommunityToolkit.Mvvm/Messaging/Internals/ArrayPoolBufferWriter{T}.cs b/src/CommunityToolkit.Mvvm/Messaging/Internals/ArrayPoolBufferWriter{T}.cs index b740eb06b..d98aba133 100644 --- a/src/CommunityToolkit.Mvvm/Messaging/Internals/ArrayPoolBufferWriter{T}.cs +++ b/src/CommunityToolkit.Mvvm/Messaging/Internals/ArrayPoolBufferWriter{T}.cs @@ -58,7 +58,7 @@ public static ArrayPoolBufferWriter Create() /// /// Gets a with the current items. /// - public ReadOnlySpan Span + public readonly ReadOnlySpan Span { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => this.span.Slice(0, this.index); @@ -116,7 +116,7 @@ private void ResizeBufferAndAdd(T item) } /// - public void Dispose() + public readonly void Dispose() { Array.Clear(this.array, 0, this.index); diff --git a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Collections.Generic/Dictionary2.cs b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Collections.Generic/Dictionary2.cs index 4e8bbf075..720cd5184 100644 --- a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Collections.Generic/Dictionary2.cs +++ b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Collections.Generic/Dictionary2.cs @@ -320,7 +320,7 @@ public bool MoveNext() /// Gets the current key. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TKey GetKey() + public readonly TKey GetKey() { return this.entries[this.index - 1].Key; } @@ -329,7 +329,7 @@ public TKey GetKey() /// Gets the current value. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TValue GetValue() + public readonly TValue GetValue() { return this.entries[this.index - 1].Value!; } diff --git a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.Proxy.cs b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.Proxy.cs index 6a7874f2a..4a1aff615 100644 --- a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.Proxy.cs +++ b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.Proxy.cs @@ -72,13 +72,13 @@ public Enumerator(ConditionalWeakTable2 owner) } /// - public void Dispose() + public readonly void Dispose() { this.enumerator.Dispose(); } /// - public bool MoveNext() + public readonly bool MoveNext() { return this.enumerator.MoveNext(); } @@ -87,7 +87,7 @@ public bool MoveNext() /// Gets the current key. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TKey GetKey() + public readonly TKey GetKey() { return this.enumerator.Current.Key; } @@ -96,7 +96,7 @@ public TKey GetKey() /// Gets the current value. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TValue GetValue() + public readonly TValue GetValue() { return this.enumerator.Current.Value; } diff --git a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.ZeroAlloc.cs b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.ZeroAlloc.cs index 882b6bf50..888f6df7e 100644 --- a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.ZeroAlloc.cs +++ b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.ZeroAlloc.cs @@ -248,7 +248,7 @@ public bool MoveNext() /// Gets the current key. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TKey GetKey() + public readonly TKey GetKey() { return this.key!; } @@ -257,7 +257,7 @@ public TKey GetKey() /// Gets the current value. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TValue GetValue() + public readonly TValue GetValue() { return this.value!; } diff --git a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.cs b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.cs index 04b6b0f2c..aba57ab7f 100644 --- a/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.cs +++ b/src/CommunityToolkit.Mvvm/Messaging/Internals/System/Runtime.CompilerServices/ConditionalWeakTable2{TKey,TValue}.cs @@ -139,7 +139,7 @@ public Enumerator(ConditionalWeakTable2 owner) } /// - public void Dispose() + public readonly void Dispose() { } @@ -189,7 +189,7 @@ public bool MoveNext() /// Gets the current key. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TKey GetKey() + public readonly TKey GetKey() { return this.key!; } @@ -198,7 +198,7 @@ public TKey GetKey() /// Gets the current value. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public TValue GetValue() + public readonly TValue GetValue() { return this.value!; } diff --git a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj index 920b2cd7b..66927f690 100644 --- a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj +++ b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj index 150c0d3f8..41d7c5c2b 100644 --- a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj +++ b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj index 516a2e527..904248c05 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs index 924bdc6bb..1d18e9d72 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ObjectMarshal.cs @@ -70,7 +70,7 @@ internal struct TestStruct : IEquatable public string Text; /// - public bool Equals(TestStruct other) + public readonly bool Equals(TestStruct other) { return this.Number == other.Number && diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Box{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Box{T}.cs index 2a3115c46..242b0bdd9 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Box{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Test_Box{T}.cs @@ -36,7 +36,7 @@ internal struct TestStruct : IEquatable public string Text; /// - public bool Equals(TestStruct other) + public readonly bool Equals(TestStruct other) { return this.Number == other.Number && 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 388b7f394..8a322c0f1 100644 --- a/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj @@ -5,8 +5,8 @@ - - + + 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 430fab996..6baf9c2df 100644 --- a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj @@ -5,8 +5,8 @@ - - + + 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 17ecba754..e5fdf4c48 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests/CommunityToolkit.Mvvm.Roslyn4001.UnitTests.csproj @@ -7,11 +7,11 @@ - - + + - + 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 f027142a5..f5b4effe5 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests/CommunityToolkit.Mvvm.Roslyn4031.UnitTests.csproj @@ -7,11 +7,11 @@ - - + + - + diff --git a/tests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests.csproj index a1fb65d0c..cf2a62e16 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.Roslyn4120.UnitTests.csproj @@ -12,11 +12,11 @@ - - + + - + 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 eaa0f012c..116adc784 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 @@ -9,8 +9,8 @@ - - + + 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 6aa049262..2e08cddd6 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 @@ -14,8 +14,8 @@ - - + + diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests.csproj index 7d0387bee..5bb5245b9 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn4120.UnitTests.csproj @@ -10,8 +10,8 @@ - - + +