Why does [ObservableProperty] require partial property in some cases but not in others?
#2748
-
|
❓ Question I'm encountering an inconsistency with In many of my view models, I have private fields like this: [ObservableProperty]
private HtmlWebViewSource? _sourceData;...and they work perfectly fine. However, in one case, I'm getting the following compiler error: I changed the declaration to a property just to check: [ObservableProperty]
public partial HtmlWebViewSource? SourceData { get; set; }...but that gives the same error: it now expects a matching implementation, which of course isn’t written manually. After reading the docs and examining the working code, I realized:
🤔 My Question(s):
💡 What I've Tried:
🔧 Version Info:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You need to set your LangVersion to preview in order to use partial properties. Inside your csproj file you need to add the following inside your <LangVersion>preview</LangVersion> |
Beta Was this translation helpful? Give feedback.
-
|
This question should be closed and/or moved to the correct Github repository, i.e. https://github.com/CommunityToolkit/dotnet/discussions |
Beta Was this translation helpful? Give feedback.
This question should be closed and/or moved to the correct Github repository, i.e. https://github.com/CommunityToolkit/dotnet/discussions