-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for OAPH nullability for reference types (#126)
* Fix for OAPH nullability for reference types Added Nested Project test to prove inheritance can operate * Add IsNullable, Fix tests
- Loading branch information
1 parent
9c1feac
commit 311fde1
Showing
16 changed files
with
372 additions
and
14 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ributeNullableRef#ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs | ||
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
// <auto-generated/> | ||
#pragma warning disable | ||
#nullable enable | ||
namespace ReactiveUI.SourceGenerators; | ||
|
||
/// <summary> | ||
/// ObservableAsPropertyAttribute. | ||
/// </summary> | ||
/// <seealso cref="Attribute" /> | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
internal sealed class ObservableAsPropertyAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Gets the name of the property. | ||
/// </summary> | ||
/// <value> | ||
/// The name of the property. | ||
/// </value> | ||
public string? PropertyName { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the Readonly state of the OAPH property. | ||
/// </summary> | ||
/// <value> | ||
/// The is read only of the OAPH property. | ||
/// </value> | ||
public bool ReadOnly { get; init; } = true; | ||
} | ||
#nullable restore | ||
#pragma warning restore |
34 changes: 34 additions & 0 deletions
34
...ropertiesWithAttributeNullableRef#TestVM.ObservableAsPropertyFromObservable.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//HintName: TestVM.ObservableAsPropertyFromObservable.g.cs | ||
// <auto-generated/> | ||
using ReactiveUI; | ||
|
||
#pragma warning disable | ||
#nullable enable | ||
|
||
namespace TestNs | ||
{ | ||
/// <summary> | ||
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. | ||
/// </summary> | ||
public partial class TestVM | ||
{ | ||
/// <inheritdoc cref="Test7Property"/> | ||
private object? _test7Property; | ||
|
||
/// <inheritdoc cref="_test7PropertyHelper"/> | ||
private ReactiveUI.ObservableAsPropertyHelper<object?>? _test7PropertyHelper; | ||
|
||
/// <inheritdoc cref="_test7Property"/> | ||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.Text.Json.Serialization.JsonIncludeAttribute()] | ||
public object? Test7Property { get => _test7Property = (_test7PropertyHelper == null ? _test7Property : _test7PropertyHelper.Value); } | ||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
protected void InitializeOAPH() | ||
{ | ||
_test7PropertyHelper = Test7!.ToProperty(this, nameof(Test7Property)); | ||
} | ||
} | ||
} | ||
#nullable restore | ||
#pragma warning restore |
38 changes: 38 additions & 0 deletions
38
...sWithAttributeRef#ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs | ||
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
// <auto-generated/> | ||
#pragma warning disable | ||
#nullable enable | ||
namespace ReactiveUI.SourceGenerators; | ||
|
||
/// <summary> | ||
/// ObservableAsPropertyAttribute. | ||
/// </summary> | ||
/// <seealso cref="Attribute" /> | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] | ||
internal sealed class ObservableAsPropertyAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Gets the name of the property. | ||
/// </summary> | ||
/// <value> | ||
/// The name of the property. | ||
/// </value> | ||
public string? PropertyName { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the Readonly state of the OAPH property. | ||
/// </summary> | ||
/// <value> | ||
/// The is read only of the OAPH property. | ||
/// </value> | ||
public bool ReadOnly { get; init; } = true; | ||
} | ||
#nullable restore | ||
#pragma warning restore |
34 changes: 34 additions & 0 deletions
34
...ervablePropertiesWithAttributeRef#TestVM.ObservableAsPropertyFromObservable.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//HintName: TestVM.ObservableAsPropertyFromObservable.g.cs | ||
// <auto-generated/> | ||
using ReactiveUI; | ||
|
||
#pragma warning disable | ||
#nullable enable | ||
|
||
namespace TestNs | ||
{ | ||
/// <summary> | ||
/// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. | ||
/// </summary> | ||
public partial class TestVM | ||
{ | ||
/// <inheritdoc cref="Test6Property"/> | ||
private object _test6Property; | ||
|
||
/// <inheritdoc cref="_test6PropertyHelper"/> | ||
private ReactiveUI.ObservableAsPropertyHelper<object>? _test6PropertyHelper; | ||
|
||
/// <inheritdoc cref="_test6Property"/> | ||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.Text.Json.Serialization.JsonIncludeAttribute()] | ||
public object Test6Property { get => _test6Property = _test6PropertyHelper?.Value ?? _test6Property; } | ||
|
||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
protected void InitializeOAPH() | ||
{ | ||
_test6PropertyHelper = Test6!.ToProperty(this, nameof(Test6Property)); | ||
} | ||
} | ||
} | ||
#nullable restore | ||
#pragma warning restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using ReactiveUI; | ||
using ReactiveUI.SourceGenerators; | ||
|
||
namespace SGReactiveUI.SourceGenerators.Execute.Nested1; | ||
|
||
/// <summary> | ||
/// Class1. | ||
/// </summary> | ||
public partial class Class1 : ReactiveObject | ||
{ | ||
[Reactive] | ||
private string? _property1; | ||
} |
17 changes: 17 additions & 0 deletions
17
...iveUI.SourceGenerators.Execute.Nested1/ReactiveUI.SourceGenerators.Execute.Nested1.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ReactiveUI" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using ReactiveUI; | ||
using ReactiveUI.SourceGenerators; | ||
|
||
namespace SGReactiveUI.SourceGenerators.Execute.Nested2; | ||
|
||
/// <summary> | ||
/// Class1. | ||
/// </summary> | ||
public partial class Class1 : ReactiveObject | ||
{ | ||
[Reactive] | ||
private string? _property1; | ||
} |
14 changes: 14 additions & 0 deletions
14
...iveUI.SourceGenerators.Execute.Nested2/ReactiveUI.SourceGenerators.Execute.Nested2.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" /> | ||
<ProjectReference Include="..\ReactiveUI.SourceGenerators.Execute.Nested1\ReactiveUI.SourceGenerators.Execute.Nested1.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using ReactiveUI; | ||
using ReactiveUI.SourceGenerators; | ||
|
||
namespace SGReactiveUI.SourceGenerators.Execute.Nested3; | ||
|
||
/// <summary> | ||
/// Class1. | ||
/// </summary> | ||
public partial class Class1 : ReactiveObject | ||
{ | ||
[Reactive] | ||
private string? _property1; | ||
} |
16 changes: 16 additions & 0 deletions
16
...iveUI.SourceGenerators.Execute.Nested3/ReactiveUI.SourceGenerators.Execute.Nested3.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<LangVersion>12.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" /> | ||
<ProjectReference Include="..\ReactiveUI.SourceGenerators.Execute.Nested2\ReactiveUI.SourceGenerators.Execute.Nested2.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.