@@ -169,5 +169,73 @@ public partial class TestVM : ReactiveObject
169169 return VerifyGenerator ( driver ) ;
170170 }
171171
172+ /// <summary>
173+ /// Tests that the source generator correctly generates observable properties.
174+ /// </summary>
175+ /// <returns>A task to monitor the async.</returns>
176+ [ Fact ]
177+ public Task FromObservablePropertiesWithAttributeRef ( )
178+ {
179+ // Arrange: Setup the source code that matches the generator input expectations.
180+ const string sourceCode = """
181+ using System;
182+ using System.Runtime.Serialization;
183+ using System.Text.Json.Serialization;
184+ using ReactiveUI;
185+ using ReactiveUI.SourceGenerators;
186+ using System.Reactive.Linq;
187+
188+ namespace TestNs;
189+
190+ public partial class TestVM : ReactiveObject
191+ {
192+ [ObservableAsProperty(PropertyName = "MyNamedProperty")]
193+ [property: JsonInclude]
194+ [DataMember]
195+ public IObservable<object> Test6 => Observable.Return(new object());
196+ }
197+ """ ;
198+
199+ // Act: Initialize the helper and run the generator.
200+ var driver = TestHelper . TestPass ( sourceCode ) ;
201+
202+ // Assert: Verify the generated code.
203+ return VerifyGenerator ( driver ) ;
204+ }
205+
206+ /// <summary>
207+ /// Tests that the source generator correctly generates observable properties.
208+ /// </summary>
209+ /// <returns>A task to monitor the async.</returns>
210+ [ Fact ]
211+ public Task FromObservablePropertiesWithAttributeNullableRef ( )
212+ {
213+ // Arrange: Setup the source code that matches the generator input expectations.
214+ const string sourceCode = """
215+ using System;
216+ using System.Runtime.Serialization;
217+ using System.Text.Json.Serialization;
218+ using ReactiveUI;
219+ using ReactiveUI.SourceGenerators;
220+ using System.Reactive.Linq;
221+
222+ namespace TestNs;
223+
224+ public partial class TestVM : ReactiveObject
225+ {
226+ [ObservableAsProperty(PropertyName = "MyNamedProperty")]
227+ [property: JsonInclude]
228+ [DataMember]
229+ public IObservable<object?> Test7 => Observable.Return(new object());
230+ }
231+ """ ;
232+
233+ // Act: Initialize the helper and run the generator.
234+ var driver = TestHelper . TestPass ( sourceCode ) ;
235+
236+ // Assert: Verify the generated code.
237+ return VerifyGenerator ( driver ) ;
238+ }
239+
172240 private SettingsTask VerifyGenerator ( GeneratorDriver driver ) => Verify ( driver ) . UseDirectory ( TestHelper . VerifiedFilePath ( ) ) . ScrubLinesContaining ( "[global::System.CodeDom.Compiler.GeneratedCode(\" " ) ;
173241}
0 commit comments