Skip to content

Commit 6f20b26

Browse files
committed
Switch attribute property setters to init-only
1 parent f81cf4b commit 6f20b26

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

CommunityToolkit.Mvvm/ComponentModel/Attributes/INotifyPropertyChangedAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public sealed class INotifyPropertyChangedAttribute : Attribute
3535
/// the two <see cref="ObservableObject.OnPropertyChanged(PropertyChangedEventArgs)"/> overloads will be generated.
3636
/// The default value is <see langword="true"/>.
3737
/// </summary>
38-
public bool IncludeAdditionalHelperMethods { get; set; } = true;
38+
public bool IncludeAdditionalHelperMethods { get; init; } = true;
3939
}

CommunityToolkit.Mvvm/Input/Attributes/ICommandAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public sealed class ICommandAttribute : Attribute
6969
/// generated command can be executed at any given time. The referenced member needs to return
7070
/// a <see cref="bool"/> value, and has to have a signature compatible with the target command.
7171
/// </summary>
72-
public string? CanExecute { get; set; }
72+
public string? CanExecute { get; init; }
7373

7474
/// <summary>
7575
/// Gets or sets a value indicating whether or not to allow concurrent executions for an asynchronous command.
@@ -78,5 +78,5 @@ public sealed class ICommandAttribute : Attribute
7878
/// when an execution is invoked while a previous one is still running. It is the same as creating an instance of
7979
/// these command types with a constructor such as <see cref="AsyncRelayCommand(Func{System.Threading.Tasks.Task}, bool)"/>.
8080
/// </summary>
81-
public bool AllowConcurrentExecutions { get; set; } = true;
81+
public bool AllowConcurrentExecutions { get; init; } = true;
8282
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
#if !NET6_0_OR_GREATER
6+
7+
using System.ComponentModel;
8+
9+
namespace System.Runtime.CompilerServices;
10+
11+
/// <summary>
12+
/// Reserved to be used by the compiler for tracking metadata.
13+
/// This class should not be used by developers in source code.
14+
/// </summary>
15+
[EditorBrowsable(EditorBrowsableState.Never)]
16+
internal static class IsExternalInit
17+
{
18+
}
19+
20+
#endif

0 commit comments

Comments
 (0)