Skip to content

Commit 37caf88

Browse files
committed
Improved XML docs for [ObservableProperty]
Added more info and remarks about field name conversion
1 parent eb0b475 commit 37caf88

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Microsoft.Toolkit.Mvvm/ComponentModel/Attributes/ObservablePropertyAttribute.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
2222
/// {
2323
/// [ObservableProperty]
2424
/// private string name;
25+
///
26+
/// [ObservableProperty]
27+
/// private bool isEnabled;
2528
/// }
2629
/// </code>
2730
/// </para>
@@ -34,9 +37,21 @@ namespace Microsoft.Toolkit.Mvvm.ComponentModel
3437
/// get => name;
3538
/// set => SetProperty(ref name, value);
3639
/// }
40+
///
41+
/// public bool IsEnabled
42+
/// {
43+
/// get => name;
44+
/// set => SetProperty(ref isEnabled, value);
45+
/// }
3746
/// }
3847
/// </code>
3948
/// </summary>
49+
/// <remarks>
50+
/// The generated properties will automatically use the <c>UpperCamelCase</c> format for their names,
51+
/// which will be derived from the field names. The generator can also recognize fields using either
52+
/// the <c>_lowerCamel</c> or <c>m_lowerCamel</c> naming scheme. Otherwise, the first character in the
53+
/// source field name will be converted to uppercase (eg. <c>isEnabled</c> to <c>IsEnabled</c>).
54+
/// </remarks>
4055
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
4156
public sealed class ObservablePropertyAttribute : Attribute
4257
{

0 commit comments

Comments
 (0)