You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: #370 [ObservableAsProperty] on partial property not initializing backing field -> Doesn't work with empty string #406
A brief initial report, please let me know if you'd like a full repro.
Setting InitialValue for ObservableAsProperty on a (not-nullable) string to empty string doesn't work. FYI in this case the initialization is I think practically a placeholder as the IObservable will provide the "real" value once set. This makes me wonder if InitialValue should actually be necessary in this case, i.e. should initialization to empty string occur automatically?
(I've also been idly pondering if InitialValue should be typed to object? which is what the NUnit [TestCase] uses for parameters allowing values to be written "normally" i.e. no quotes on an int literal and so on - and shock horror, this also makes me wonder if I should be tiptoeing towards technical contribution...)
This user code:
[ObservableAsProperty(InitialValue = "")]
public partial string PLCActive { get; }
Leads to this generated code:
///
private string _pLCActive;
It should be:
///
private string _pLCActive = "";
Step to reproduce
Create a non-nullable string OAPH property without InitialValue, this will lead to a nullability warning "not initialized"
Add InitialValue = "", still "not initialized.
Change this to i.e. InitialValue = "?", no longer a warning
Activity
ChrisPulman commentedon Apr 29, 2026
Thanks for raising this, I will try to get this resolved as soon as possible.
github-actions commentedon Sep 1, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.