From 0bf69ba43fff5fb436e24af71798883e1c376f53 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Tue, 31 Dec 2024 22:44:09 +0000 Subject: [PATCH 1/2] Fix For Reactive Property with Nested Classes --- .../TestViewModel3.cs | 66 +++++++++++-------- .../Core/Models/TargetInfo.cs | 58 +++++++++++++++- .../IViewFor/IViewForGenerator.Execute.cs | 7 +- .../IViewFor/IViewForGenerator.cs | 2 +- .../IViewFor/Models/IViewForInfo.cs | 8 +-- .../Models/ObservableFieldInfo.cs | 8 +-- .../Models/ObservableMethodInfo.cs | 24 +++---- ...eAsPropertyGenerator{FromField}.Execute.cs | 7 +- ...bservableAsPropertyGenerator{FromField}.cs | 2 +- ...opertyGenerator{FromObservable}.Execute.cs | 14 +--- ...ableAsPropertyGenerator{FromObservable}.cs | 2 +- .../Reactive/Models/PropertyInfo.cs | 8 +-- .../Reactive/ReactiveGenerator.Execute.cs | 54 +++++++++++---- .../Reactive/ReactiveGenerator.cs | 2 +- .../ReactiveCommand/Models/CommandInfo.cs | 8 +-- .../ReactiveCommandGenerator.Execute.cs | 7 +- .../ReactiveCommandGenerator.cs | 2 +- 17 files changed, 164 insertions(+), 115 deletions(-) diff --git a/src/ReactiveUI.SourceGenerators.Execute/TestViewModel3.cs b/src/ReactiveUI.SourceGenerators.Execute/TestViewModel3.cs index 54ef829..007b9b3 100644 --- a/src/ReactiveUI.SourceGenerators.Execute/TestViewModel3.cs +++ b/src/ReactiveUI.SourceGenerators.Execute/TestViewModel3.cs @@ -16,31 +16,43 @@ public partial class TestViewModel3 : ReactiveObject [Reactive] private float _testVM3Property; - /////// - /////// TestInnerClass. - /////// - ////public partial class TestInnerClass1 : ReactiveObject - ////{ - //// [Reactive] - //// private int _testInner1; - ////} - - /////// - /////// TestInnerClass. - /////// - ////public partial class TestInnerClass2 : ReactiveObject - ////{ - //// [Reactive] - //// private int _testInner2; - - //// /// - //// /// TestInnerClass4. - //// /// - //// /// - //// public partial class TestInnerClass3 : ReactiveObject - //// { - //// [Reactive] - //// private int _testInner3; - //// } - ////} + [Reactive] + private float _testVM3Property2; + + /// + /// TestInnerClass. + /// + public partial class TestInnerClass1 : ReactiveObject + { + [Reactive] + private int _testInner1; + + [Reactive] + private int _testInner11; + } + + /// + /// TestInnerClass. + /// + public partial class TestInnerClass2 : ReactiveObject + { + [Reactive] + private int _testInner2; + + [Reactive] + private int _testInner22; + + /// + /// TestInnerClass4. + /// + /// + public partial class TestInnerClass3 : ReactiveObject + { + [Reactive] + private int _testInner3; + + [Reactive] + private int _testInner33; + } + } } diff --git a/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs b/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs index a744fa7..c8f5e50 100644 --- a/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs +++ b/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs @@ -3,6 +3,7 @@ // 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.Collections.Generic; using Microsoft.CodeAnalysis; using ReactiveUI.SourceGenerators.Extensions; using ReactiveUI.SourceGenerators.Helpers; @@ -15,7 +16,8 @@ internal sealed partial record TargetInfo( string TargetNamespace, string TargetNamespaceWithNamespace, string TargetVisibility, - string TargetType) + string TargetType, + TargetInfo? ParentInfo) { public static TargetInfo From(INamedTypeSymbol namedTypeSymbol) { @@ -26,12 +28,64 @@ public static TargetInfo From(INamedTypeSymbol namedTypeSymbol) var targetAccessibility = namedTypeSymbol.GetAccessibilityString(); var targetType = namedTypeSymbol.GetTypeString(); + var parentInfo = namedTypeSymbol.ContainingType is not null + ? From(namedTypeSymbol.ContainingType) + : null; + return new( targetHintName, targetName, targetNamespace, targetNameWithNamespace, targetAccessibility, - targetType); + targetType, + parentInfo); + } + + public static void GetParentClasses(ref List parentClassDeclarations, TargetInfo? targetInfo) + { + if (targetInfo is not null) + { + var parentClassDeclaration = $"{targetInfo.TargetVisibility} partial {targetInfo.TargetType} {targetInfo.TargetName}"; + + // Add the parent class declaration if it does not exist in the list + if (!parentClassDeclarations.Contains(parentClassDeclaration)) + { + parentClassDeclarations.Add(parentClassDeclaration); + } + + if (targetInfo.ParentInfo is not null) + { + // Recursively get the parent classes + GetParentClasses(ref parentClassDeclarations, targetInfo.ParentInfo); + } + } + } + + public static string GenerateParentClassDeclarations(ref List parentClassDeclarations) + { + // Reverse the list to get the parent classes in the correct order + parentClassDeclarations.Reverse(); + + // Generate the parent class declarations + var parentClassDeclarationsString = string.Join("\n{\n", parentClassDeclarations); + if (!string.IsNullOrWhiteSpace(parentClassDeclarationsString)) + { + parentClassDeclarationsString += "\n{\n"; + } + + return parentClassDeclarationsString; + } + + public static string GenerateClosingBrackets(int numberOfBrackets) + { + var closingBrackets = new string('}', numberOfBrackets); + closingBrackets = closingBrackets.Replace("}", "}\n"); + if (!string.IsNullOrWhiteSpace(closingBrackets)) + { + closingBrackets = "\n" + closingBrackets; + } + + return closingBrackets; } } diff --git a/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.Execute.cs b/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.Execute.cs index d09f18f..14606e6 100644 --- a/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.Execute.cs +++ b/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.Execute.cs @@ -92,12 +92,7 @@ public partial class IViewForGenerator token.ThrowIfCancellationRequested(); return new( - targetInfo.FileHintName, - targetInfo.TargetName, - targetInfo.TargetNamespace, - targetInfo.TargetNamespaceWithNamespace, - targetInfo.TargetVisibility, - targetInfo.TargetType, + targetInfo, viewModelTypeName!, viewForBaseType); } diff --git a/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.cs b/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.cs index 717ca9d..cb2e7c2 100644 --- a/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.cs +++ b/src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.cs @@ -40,7 +40,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) context.RegisterSourceOutput(iViewForInfo, static (context, input) => { var groupedPropertyInfo = input.GroupBy( - static info => (info.FileHintName, info.TargetName, info.TargetNamespace, info.TargetVisibility, info.TargetType), + static info => (info.TargetInfo.FileHintName, info.TargetInfo.TargetName, info.TargetInfo.TargetNamespace, info.TargetInfo.TargetVisibility, info.TargetInfo.TargetType), static info => info) .ToImmutableArray(); diff --git a/src/ReactiveUI.SourceGenerators/IViewFor/Models/IViewForInfo.cs b/src/ReactiveUI.SourceGenerators/IViewFor/Models/IViewForInfo.cs index c953459..27f4c4c 100644 --- a/src/ReactiveUI.SourceGenerators/IViewFor/Models/IViewForInfo.cs +++ b/src/ReactiveUI.SourceGenerators/IViewFor/Models/IViewForInfo.cs @@ -4,6 +4,7 @@ // See the LICENSE file in the project root for full license information. using ReactiveUI.SourceGenerators.Helpers; +using ReactiveUI.SourceGenerators.Models; namespace ReactiveUI.SourceGenerators.Input.Models; @@ -11,11 +12,6 @@ namespace ReactiveUI.SourceGenerators.Input.Models; /// A model with gathered info on a given command method. /// internal sealed record IViewForInfo( - string FileHintName, - string TargetName, - string TargetNamespace, - string TargetNamespaceWithNamespace, - string TargetVisibility, - string TargetType, + TargetInfo TargetInfo, string ViewModelTypeName, IViewForBaseType BaseType); diff --git a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableFieldInfo.cs b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableFieldInfo.cs index 953fbfc..bb1e12d 100644 --- a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableFieldInfo.cs +++ b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableFieldInfo.cs @@ -4,6 +4,7 @@ // See the LICENSE file in the project root for full license information. using ReactiveUI.SourceGenerators.Helpers; +using ReactiveUI.SourceGenerators.Models; namespace ReactiveUI.SourceGenerators.Reactive.Models; @@ -11,12 +12,7 @@ namespace ReactiveUI.SourceGenerators.Reactive.Models; /// A model with gathered info on a given field. /// internal sealed record ObservableFieldInfo( - string FileHintName, - string TargetName, - string TargetNamespace, - string TargetNamespaceWithNamespace, - string TargetVisibility, - string TargetType, + TargetInfo TargetInfo, string TypeNameWithNullabilityAnnotations, string FieldName, string PropertyName, diff --git a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableMethodInfo.cs b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableMethodInfo.cs index a335d4a..51c42b6 100644 --- a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableMethodInfo.cs +++ b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/Models/ObservableMethodInfo.cs @@ -5,24 +5,20 @@ using System.Globalization; using ReactiveUI.SourceGenerators.Helpers; +using ReactiveUI.SourceGenerators.Models; namespace ReactiveUI.SourceGenerators.ObservableAsProperty.Models { internal record ObservableMethodInfo( - string FileHintName, - string TargetName, - string TargetNamespace, - string TargetNamespaceWithNamespace, - string TargetVisibility, - string TargetType, - string MethodName, - string MethodReturnType, - string? ArgumentType, - string PropertyName, - string ObservableType, - bool IsNullableType, - bool IsProperty, - EquatableArray ForwardedPropertyAttributes) + TargetInfo TargetInfo, + string MethodName, + string MethodReturnType, + string? ArgumentType, + string PropertyName, + string ObservableType, + bool IsNullableType, + bool IsProperty, + EquatableArray ForwardedPropertyAttributes) { public string GetGeneratedFieldName() { diff --git a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.Execute.cs b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.Execute.cs index 6be5f25..cf3a244 100644 --- a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.Execute.cs +++ b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.Execute.cs @@ -195,12 +195,7 @@ public sealed partial class ObservableAsPropertyGenerator return new( new( - targetInfo.FileHintName, - targetInfo.TargetName, - targetInfo.TargetNamespace, - targetInfo.TargetNamespaceWithNamespace, - targetInfo.TargetVisibility, - targetInfo.TargetType, + targetInfo, typeNameWithNullabilityAnnotations, fieldName, propertyName, diff --git a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.cs b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.cs index 61d6aa4..deee37f 100644 --- a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.cs +++ b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromField}.cs @@ -42,7 +42,7 @@ private static void RunObservableAsPropertyFromField(in IncrementalGeneratorInit var groupedPropertyInfo = input .Where(static x => x.Value != null) .Select(static x => x.Value!).GroupBy( - static info => (info.FileHintName, info.TargetName, info.TargetNamespace, info.TargetVisibility, info.TargetType), + static info => (info.TargetInfo.FileHintName, info.TargetInfo.TargetName, info.TargetInfo.TargetNamespace, info.TargetInfo.TargetVisibility, info.TargetInfo.TargetType), static info => info) .ToImmutableArray(); diff --git a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs index b584d5d..e99a768 100644 --- a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs +++ b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.Execute.cs @@ -74,12 +74,7 @@ public sealed partial class ObservableAsPropertyGenerator return new( new( - targetInfo.FileHintName, - targetInfo.TargetName, - targetInfo.TargetNamespace, - targetInfo.TargetNamespaceWithNamespace, - targetInfo.TargetVisibility, - targetInfo.TargetType, + targetInfo, methodSymbol.Name, methodSymbol.ReturnType.GetFullyQualifiedNameWithNullabilityAnnotations(), methodSymbol.Parameters.FirstOrDefault()?.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), @@ -120,12 +115,7 @@ public sealed partial class ObservableAsPropertyGenerator return new( new( - targetInfo.FileHintName, - targetInfo.TargetName, - targetInfo.TargetNamespace, - targetInfo.TargetNamespaceWithNamespace, - targetInfo.TargetVisibility, - targetInfo.TargetType, + targetInfo, propertySymbol.Name, propertySymbol.Type.GetFullyQualifiedNameWithNullabilityAnnotations(), propertySymbol.Parameters.FirstOrDefault()?.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), diff --git a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.cs b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.cs index 00cc59d..72b5067 100644 --- a/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.cs +++ b/src/ReactiveUI.SourceGenerators/ObservableAsProperty/ObservableAsPropertyGenerator{FromObservable}.cs @@ -45,7 +45,7 @@ private static void RunObservableAsPropertyFromObservable(in IncrementalGenerato var groupedPropertyInfo = input .Where(static x => x.Value != null) .Select(static x => x.Value!).GroupBy( - static info => (info.FileHintName, info.TargetName, info.TargetNamespace, info.TargetVisibility, info.TargetType), + static info => (info.TargetInfo.FileHintName, info.TargetInfo.TargetName, info.TargetInfo.TargetNamespace, info.TargetInfo.TargetVisibility, info.TargetInfo.TargetType), static info => info) .ToImmutableArray(); diff --git a/src/ReactiveUI.SourceGenerators/Reactive/Models/PropertyInfo.cs b/src/ReactiveUI.SourceGenerators/Reactive/Models/PropertyInfo.cs index ef77107..9908c3e 100644 --- a/src/ReactiveUI.SourceGenerators/Reactive/Models/PropertyInfo.cs +++ b/src/ReactiveUI.SourceGenerators/Reactive/Models/PropertyInfo.cs @@ -4,6 +4,7 @@ // See the LICENSE file in the project root for full license information. using ReactiveUI.SourceGenerators.Helpers; +using ReactiveUI.SourceGenerators.Models; namespace ReactiveUI.SourceGenerators.Reactive.Models; @@ -11,12 +12,7 @@ namespace ReactiveUI.SourceGenerators.Reactive.Models; /// A model with gathered info on a given field. /// internal sealed record PropertyInfo( - string FileHintName, - string TargetName, - string TargetNamespace, - string TargetNamespaceWithNamespace, - string TargetVisibility, - string TargetType, + TargetInfo TargetInfo, string TypeNameWithNullabilityAnnotations, string FieldName, string PropertyName, diff --git a/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.Execute.cs b/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.Execute.cs index 6970112..620ecfa 100644 --- a/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.Execute.cs +++ b/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.Execute.cs @@ -4,6 +4,7 @@ // See the LICENSE file in the project root for full license information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading; @@ -210,12 +211,7 @@ public sealed partial class ReactiveGenerator return new( new( - targetInfo.FileHintName, - targetInfo.TargetName, - targetInfo.TargetNamespace, - targetInfo.TargetNamespaceWithNamespace, - targetInfo.TargetVisibility, - targetInfo.TargetType, + targetInfo, typeNameWithNullabilityAnnotations, fieldName, propertyName, @@ -238,8 +234,20 @@ public sealed partial class ReactiveGenerator /// The value. private static string GenerateSource(string containingTypeName, string containingNamespace, string containingClassVisibility, string containingType, PropertyInfo[] properties) { - // Includes 2 tabs from the property declarations so no need to add them here. - var propertyDeclarations = string.Join("\n\r", properties.Select(GetPropertySyntax)); + // Get Parent class details from properties.ParentInfo + var parentClassDeclarations = new List(); + foreach (var property in properties) + { + TargetInfo.GetParentClasses(ref parentClassDeclarations, property.TargetInfo.ParentInfo); + } + + // Generate the parent class declarations + var parentClassDeclarationsString = TargetInfo.GenerateParentClassDeclarations(ref parentClassDeclarations); + + var classes = GenerateClassWithProperties(containingTypeName, containingNamespace, containingClassVisibility, containingType, properties); + + // Create closing brackets for parent classes + var closingBrackets = TargetInfo.GenerateClosingBrackets(parentClassDeclarations.Count); return $$""" @@ -251,6 +259,29 @@ private static string GenerateSource(string containingTypeName, string containin namespace {{containingNamespace}} { + {{parentClassDeclarationsString}}{{classes}}{{closingBrackets}} +} +#nullable restore +#pragma warning restore +"""; + } + + /// + /// Generates the source code. + /// + /// The contain type name. + /// The containing namespace. + /// The containing class visibility. + /// The containing type. + /// The properties. + /// The value. + private static string GenerateClassWithProperties(string containingTypeName, string containingNamespace, string containingClassVisibility, string containingType, PropertyInfo[] properties) + { + // Includes 2 tabs from the property declarations so no need to add them here. + var propertyDeclarations = string.Join("\n\r", properties.Select(GetPropertySyntax)); + + return +$$""" /// /// Partial class for the {{containingTypeName}} which contains ReactiveUI Reactive property initialization. /// @@ -259,9 +290,6 @@ namespace {{containingNamespace}} [global::System.CodeDom.Compiler.GeneratedCode("{{GeneratorName}}", "{{GeneratorVersion}}")] {{propertyDeclarations}} } -} -#nullable restore -#pragma warning restore """; } @@ -285,7 +313,7 @@ private static string GetPropertySyntax(PropertyInfo propertyInfo) $$""" /// {{propertyAttributes}} - {{propertyInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} + {{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{propertyInfo.FieldName}}; [global::System.Diagnostics.CodeAnalysis.MemberNotNull("{{propertyInfo.FieldName}}")] @@ -298,7 +326,7 @@ private static string GetPropertySyntax(PropertyInfo propertyInfo) $$""" /// {{propertyAttributes}} - {{propertyInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{propertyInfo.FieldName}}; {{propertyInfo.AccessModifier}}set => this.RaiseAndSetIfChanged(ref {{propertyInfo.FieldName}}, value); } + {{propertyInfo.TargetInfo.TargetVisibility}}{{propertyInfo.Inheritance}} {{propertyInfo.TypeNameWithNullabilityAnnotations}} {{propertyInfo.PropertyName}} { get => {{propertyInfo.FieldName}}; {{propertyInfo.AccessModifier}}set => this.RaiseAndSetIfChanged(ref {{propertyInfo.FieldName}}, value); } """; } diff --git a/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.cs b/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.cs index 835eaac..313cc19 100644 --- a/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.cs +++ b/src/ReactiveUI.SourceGenerators/Reactive/ReactiveGenerator.cs @@ -56,7 +56,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var groupedPropertyInfo = input .Where(static x => x.Value != null) .Select(static x => x.Value!).GroupBy( - static info => (info.FileHintName, info.TargetName, info.TargetNamespace, info.TargetVisibility, info.TargetType), + static info => (info.TargetInfo.FileHintName, info.TargetInfo.TargetName, info.TargetInfo.TargetNamespace, info.TargetInfo.TargetVisibility, info.TargetInfo.TargetType), static info => info) .ToImmutableArray(); diff --git a/src/ReactiveUI.SourceGenerators/ReactiveCommand/Models/CommandInfo.cs b/src/ReactiveUI.SourceGenerators/ReactiveCommand/Models/CommandInfo.cs index 482ed98..3f4a5e9 100644 --- a/src/ReactiveUI.SourceGenerators/ReactiveCommand/Models/CommandInfo.cs +++ b/src/ReactiveUI.SourceGenerators/ReactiveCommand/Models/CommandInfo.cs @@ -4,16 +4,12 @@ // See the LICENSE file in the project root for full license information. using ReactiveUI.SourceGenerators.Helpers; +using ReactiveUI.SourceGenerators.Models; namespace ReactiveUI.SourceGenerators.Input.Models; internal record CommandInfo( - string FileHintName, - string TargetName, - string TargetNamespace, - string TargetNamespaceWithNamespace, - string TargetVisibility, - string TargetType, + TargetInfo TargetInfo, string MethodName, string MethodReturnType, string? ArgumentType, diff --git a/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.Execute.cs b/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.Execute.cs index 258efad..ae3f064 100644 --- a/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.Execute.cs +++ b/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.Execute.cs @@ -93,12 +93,7 @@ public partial class ReactiveCommandGenerator token.ThrowIfCancellationRequested(); return new( - targetInfo.FileHintName, - targetInfo.TargetName, - targetInfo.TargetNamespace, - targetInfo.TargetNamespaceWithNamespace, - targetInfo.TargetVisibility, - targetInfo.TargetType, + targetInfo, symbol.Name, realReturnType.GetFullyQualifiedNameWithNullabilityAnnotations(), methodParameters.ToImmutable().SingleOrDefault()?.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), diff --git a/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.cs b/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.cs index 47ca75e..909d137 100644 --- a/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.cs +++ b/src/ReactiveUI.SourceGenerators/ReactiveCommand/ReactiveCommandGenerator.cs @@ -41,7 +41,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) context.RegisterSourceOutput(commandInfo, static (context, input) => { var groupedcommandInfo = input.GroupBy( - static info => (info.FileHintName, info.TargetName, info.TargetNamespace, info.TargetVisibility, info.TargetType), + static info => (info.TargetInfo.FileHintName, info.TargetInfo.TargetName, info.TargetInfo.TargetNamespace, info.TargetInfo.TargetVisibility, info.TargetInfo.TargetType), static info => info) .ToImmutableArray(); From dbebba7071d703dd3ab80963e7cb0389611c6a01 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Tue, 31 Dec 2024 23:03:22 +0000 Subject: [PATCH 2/2] Update slight difference in output with regards to spacing --- ...operiesWithAttributes#TestNs.TestVM.Properties.g.verified.cs | 2 +- ...romReactiveProperties#TestNs.TestVM.Properties.g.verified.cs | 2 +- ...ePropertiesWithAccess#TestNs.TestVM.Properties.g.verified.cs | 2 +- ...sAccessAndInheritance#TestNs.TestVM.Properties.g.verified.cs | 2 +- ...esWithIdenticalClass#TestNs1.TestVM.Properties.g.verified.cs | 2 +- ...esWithIdenticalClass#TestNs2.TestVM.Properties.g.verified.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperiesWithAttributes#TestNs.TestVM.Properties.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperiesWithAttributes#TestNs.TestVM.Properties.g.verified.cs index 3946232..4af2052 100644 --- a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperiesWithAttributes#TestNs.TestVM.Properties.g.verified.cs +++ b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperiesWithAttributes#TestNs.TestVM.Properties.g.verified.cs @@ -7,7 +7,7 @@ namespace TestNs { - /// + /// /// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. /// public partial class TestVM diff --git a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#TestNs.TestVM.Properties.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#TestNs.TestVM.Properties.g.verified.cs index 3b48333..5f1211e 100644 --- a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#TestNs.TestVM.Properties.g.verified.cs +++ b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactiveProperties#TestNs.TestVM.Properties.g.verified.cs @@ -7,7 +7,7 @@ namespace TestNs { - /// + /// /// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. /// public partial class TestVM diff --git a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAccess#TestNs.TestVM.Properties.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAccess#TestNs.TestVM.Properties.g.verified.cs index 94971df..4705ef2 100644 --- a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAccess#TestNs.TestVM.Properties.g.verified.cs +++ b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAccess#TestNs.TestVM.Properties.g.verified.cs @@ -7,7 +7,7 @@ namespace TestNs { - /// + /// /// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. /// public partial class TestVM diff --git a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAttributesAccessAndInheritance#TestNs.TestVM.Properties.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAttributesAccessAndInheritance#TestNs.TestVM.Properties.g.verified.cs index 00d6b21..30c620f 100644 --- a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAttributesAccessAndInheritance#TestNs.TestVM.Properties.g.verified.cs +++ b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithAttributesAccessAndInheritance#TestNs.TestVM.Properties.g.verified.cs @@ -7,7 +7,7 @@ namespace TestNs { - /// + /// /// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. /// public partial class TestVM diff --git a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs1.TestVM.Properties.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs1.TestVM.Properties.g.verified.cs index 02aa8f9..4c939ee 100644 --- a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs1.TestVM.Properties.g.verified.cs +++ b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs1.TestVM.Properties.g.verified.cs @@ -7,7 +7,7 @@ namespace TestNs1 { - /// + /// /// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. /// public partial class TestVM diff --git a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs2.TestVM.Properties.g.verified.cs b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs2.TestVM.Properties.g.verified.cs index eea6ffc..f5b1066 100644 --- a/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs2.TestVM.Properties.g.verified.cs +++ b/src/ReactiveUI.SourceGenerator.Tests/REACTIVE/ReactiveGeneratorTests.FromReactivePropertiesWithIdenticalClass#TestNs2.TestVM.Properties.g.verified.cs @@ -7,7 +7,7 @@ namespace TestNs2 { - /// + /// /// Partial class for the TestVM which contains ReactiveUI Reactive property initialization. /// public partial class TestVM