Describe the bug 🐞
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
Reproduction repository
https://github.com/reactiveui/ReactiveUI
Expected behavior
Empty string should be supported, and maybe there should be no need for an InitialValue in this case?
Screenshots 🖼️
No response
IDE
Visual Studio 2022
Operating system
Windows
Version
11
Device
No response
ReactiveUI Version
ReactiveUI.SourceGenerators 2.6.30
Additional information ℹ️
No response
Describe the bug 🐞
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
Reproduction repository
https://github.com/reactiveui/ReactiveUI
Expected behavior
Empty string should be supported, and maybe there should be no need for an InitialValue in this case?
Screenshots 🖼️
No response
IDE
Visual Studio 2022
Operating system
Windows
Version
11
Device
No response
ReactiveUI Version
ReactiveUI.SourceGenerators 2.6.30
Additional information ℹ️
No response