Skip to content

Commit d7ea78f

Browse files
Fix XamlC warning for DrawingViewModel and MVVMTK warning SpeechToTextPage (#2513)
* Fix XamlC Warning for `DrawingViewModel` and `SpeechToTextPage` * Update WarningsAsErrors * Add additional MVVMTK Analyzers to `WarningsAsErrors` --------- Co-authored-by: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
1 parent 2d8db6a commit d7ea78f

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

Directory.Build.props

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,34 @@
4848
CS1712: Type parameter has no matching typeparam tag in the XML comment
4949
CS1723: XML comment has cref attribute that refers to a type parameter
5050
CS1734: XML comment has a paramref tag, but there is no parameter by that name
51-
MVMTK0042: The field [ObservableProperty] can be converted to a partial property
51+
MVVMTK0001: Cannot apply [INotifyPropertyChanged] to a type that already declares the INotifyPropertyChanged interface
52+
MVVMTK0002: Cannot apply [ObservableObject] to a type that already declares the INotifyPropertyChanged interface
53+
MVVMTK0003: Cannot apply [ObservableObject] to a type that already declares the INotifyPropertyChanging interface.
54+
MVVMTK0009: The CanExecute name in [RelayCommand] must refer to a valid member in its parent type.
55+
MVVMTK0010: Cannot set the CanExecute name in [RelayCommand] to one that has multiple matches in its parent type (it must refer to a single compatible member).
56+
MVVMTK0011: The CanExecute name in [RelayCommand] must refer to a compatible member (either a property or a method) to be used in a generated command.
57+
MVVMTK0012: Cannot apply the [RelayCommand] attribute specifying a concurrency control option to methods mapping to non-asynchronous command types
58+
MVVMTK0013: Cannot apply the [RelayCommand] attribute specifying to include a cancel command to methods not mapping to an asynchronous command type accepting a cancellation token
59+
MVVMTK0017: Cannot apply [INotifyPropertyChanged] to a type that already has this attribute or [ObservableObject] applied to it (including base types).
60+
MVVMTK0018: Cannot apply [ObservableObject] to a type that already has this attribute or [INotifyPropertyChanged] applied to it (including base types).
61+
MVVMTK0019: Fields annotated with [ObservableProperty] must be contained in a type that inherits from ObservableObject or that is annotated with [ObservableObject] or [INotifyPropertyChanged] (including base types).
62+
MVVMTK0020: Fields not annotated with [ObservableProperty] cannot use [NotifyPropertyChangedFor], [NotifyCanExecuteChangedFor], [NotifyPropertyChangedRecipients] and [NotifyDataErrorInfo].
63+
MVVMTK0023: Methods with multiple overloads cannot be annotated with [RelayCommand], as command methods must be unique within their containing type.
64+
MVVMTK0024: The fields annotated with [ObservableProperty] cannot result in a property name or have a type that would cause conflicts with other generated members.
65+
MVVMTK0032: Classes with no base types should prefer inheriting from ObservableObject instead of using attributes to generate INotifyPropertyChanged code, as that will reduce the binary size of the application (the attributes are only meant to support cases where the annotated types are already inheriting from a different type). This diagnostic applies to cases where [INotifyPropertyChanged] is used in particular.
66+
MVVMTK0033: Classes with no base types should prefer inheriting from ObservableObject instead of using attributes to generate INotifyPropertyChanged code, as that will reduce the binary size of the application (the attributes are only meant to support cases where the annotated types are already inheriting from a different type). This diagnostic applies to cases where [ObservableObject] is used in particular
67+
MVVMTK0034: Fields with [ObservableProperty] should not be directly referenced, and the generated properties should be used instead. This warning exists to help avoid cases where developers accidentally refer to backing fields of a generated property to update its value, and then see no property change notification being raised. The generated property should always be referenced instead.
68+
MVVMTK0035: All attributes targeting the generated property for a field annotated with [ObservableProperty] must correctly be resolved to valid types
69+
MVVMTK0036: All attributes targeting the generated field or property for a method annotated with [RelayCommand] must correctly be resolved to valid types
70+
MVVMTK0039: Asynchronous methods annotated with [RelayCommand] should return a Task value, and not be async void
71+
MVVMTK0042: The field [ObservableProperty] can be converted to a partial property
72+
MVVMTK0049: Using the [INotifyPropertyChanged] attribute on types is not AOT compatible in WinRT scenarios (such as UWP XAML and WinUI 3 apps), and they should derive from ObservableObject or manually implement INotifyPropertyChanged instead
73+
MVVMTK0050: Using the [ObservableObject] attribute on types is not AOT compatible in WinRT scenarios (such as UWP XAML and WinUI 3 apps), and they should derive from ObservableObject instead
74+
MVVMTK0052: [ObservableProperty] must be used on partial property definitions with no implementation part
75+
MVVMTK0053: [ObservableProperty] must be used on properties returning a type by value
76+
MVVMTK0054: [ObservableProperty] must be used on properties of a non byref-like type
77+
MVVMTK0055: [ObservableProperty] must be used on properties of a non pointer-like type
78+
MVVMTK0056: The semi-auto property can be converted to a partial property using [ObservableProperty]
5279
CsWinRT1028: Class implements WinRT interfaces but isn't marked partial
5380
CsWinRT1030: Class implements WinRT interfaces that require unsafe code
5481
NU1900 Error communicating with package source, while getting vulnerability information.
@@ -150,7 +177,7 @@
150177
nullable,
151178
CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1587,CS1589,CS1590,CS1591,CS1592,CS1598,CS1658,CS1710,CS1711,CS1712,CS1723,CS1734,
152179
CsWinRT1028,CsWinRT1030,
153-
MVMTK0042,
180+
MVVMTK0001,MVVMTK0002,MVVMTK0003,MVVMTK0009,MVVMTK0010,MVVMTK0011,MVVMTK0012,MVVMTK0013,MVVMTK0017,MVVMTK0018,MVVMTK0019,MVVMTK0020,MVVMTK0023,MVVMTK0024,MVVMTK0032,MVVMTK0033,MVVMTK0034,MVVMTK0035,MVVMTK0036,MVVMTK0039,MVVMTK0042,MVVMTK0049,MVVMTK0050,MVVMTK0052,MVVMTK0053,MVVMTK0054,MVVMTK0055,MVVMTK0056,
154181
NU1900,NU1901,NU1902,NU1903,NU1904,NU1905,
155182
xUnit1000,xUnit1001,xUnit1002,xUnit1003,xUnit1004,xUnit1005,xUnit1006,xUnit1007,xUnit1008,xUnit1009,xUnit1010,xUnit1011,xUnit1012,xUnit1013,xUnit1014,xUnit1015,xUnit1016,xUnit1017,xUnit1018,xUnit1019,xUnit1020,xUnit1021,xUnit1022,xUnit1023,xUnit1024,xUnit1025,xUnit1026,xUnit1027,xUnit1028,xUnit1029,xUnit1030,xUnit1031,xUnit1032,xUnit1033,xUnit1034,xUnit1035,xUnit1036,xUnit1037,xUnit1038,xUnit1039,xUnit1040,xUnit1041,xUnit1042,xUnit1043,xUnit1048,xUnit1049,xUnit1050,xUnit1051,
156183
xUnit2000,xUnit2001,xUnit2002,xUnit2003,xUnit2004,xUnit2005,xUnit2006,xUnit2007,xUnit2008,xUnit2009,xUnit2010,xUnit2011,xUnit2012,xUnit2013,xUnit2014,xUnit2015,xUnit2016,xUnit2017,xUnit2018,xUnit2019,xUnit2020,xUnit2021,xUnit2022,xUnit2023,xUnit2024,xUnit2025,xUnit2026,xUnit2027,xUnit2028,xUnit2029,xUnit2030,xUnit2031,xUnit2032,

samples/CommunityToolkit.Maui.Sample/Pages/Essentials/SpeechToTextPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<Picker
3030
ItemsSource="{Binding Locales}"
3131
SelectedItem="{Binding CurrentLocale}"
32-
ItemDisplayBinding="{Binding ., Converter={StaticResource PickerLocaleDisplayConverter}}"/>
32+
ItemDisplayBinding="{Binding ., x:DataType={x:Type Picker}, Converter={StaticResource PickerLocaleDisplayConverter}}"/>
3333

3434
<Label
3535
Text="State"

samples/CommunityToolkit.Maui.Sample/ViewModels/Views/DrawingViewViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ namespace CommunityToolkit.Maui.Sample.ViewModels.Views;
1313
public partial class DrawingViewViewModel : BaseViewModel
1414
{
1515
readonly IFileSaver fileSaver;
16-
16+
17+
public List<DrawingViewOutputOption> AvailableOutputOptions { get; } = [DrawingViewOutputOption.Lines, DrawingViewOutputOption.FullCanvas];
18+
1719
[ObservableProperty]
1820
public partial string Logs { get; private set; } = string.Empty;
1921

2022
[ObservableProperty]
21-
DrawingViewOutputOption selectedOutputOption = DrawingViewOutputOption.Lines;
22-
23-
public List<DrawingViewOutputOption> AvailableOutputOptions { get; } = [DrawingViewOutputOption.Lines, DrawingViewOutputOption.FullCanvas];
23+
public partial DrawingViewOutputOption SelectedOutputOption { get; set; } = DrawingViewOutputOption.Lines;
2424

2525
public double CanvasHeight { get; set; }
2626

0 commit comments

Comments
 (0)