From ace3c5834a92383306a8798b6421423f6303cbc7 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Thu, 7 Nov 2024 00:17:25 +0000 Subject: [PATCH] Fix For Generators used on Generic class --- .../TestViewModel2.cs | 20 +++++++++++++++++ .../TestViewWpf2.cs | 22 +++++++++++++++++++ .../Core/Models/HierarchyInfo.Syntax.cs | 1 - .../Core/Models/TargetInfo.cs | 7 ++---- 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 src/ReactiveUI.SourceGenerators.Execute/TestViewModel2.cs create mode 100644 src/ReactiveUI.SourceGenerators.Execute/TestViewWpf2.cs diff --git a/src/ReactiveUI.SourceGenerators.Execute/TestViewModel2.cs b/src/ReactiveUI.SourceGenerators.Execute/TestViewModel2.cs new file mode 100644 index 0000000..ee732ea --- /dev/null +++ b/src/ReactiveUI.SourceGenerators.Execute/TestViewModel2.cs @@ -0,0 +1,20 @@ +// 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.Test; + +/// +/// TestViewModel2. +/// +/// the type. +/// +public partial class TestViewModel2 : ReactiveObject +{ + [Reactive] + private bool _IsTrue; +} diff --git a/src/ReactiveUI.SourceGenerators.Execute/TestViewWpf2.cs b/src/ReactiveUI.SourceGenerators.Execute/TestViewWpf2.cs new file mode 100644 index 0000000..ddc7193 --- /dev/null +++ b/src/ReactiveUI.SourceGenerators.Execute/TestViewWpf2.cs @@ -0,0 +1,22 @@ +// 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.Windows; +using ReactiveUI.SourceGenerators; + +namespace SGReactiveUI.SourceGenerators.Test; + +/// +/// TestViewWpf2. +/// +/// +[IViewFor("TestViewModel2")] +public partial class TestViewWpf2 : Window +{ + /// + /// Initializes a new instance of the class. + /// + public TestViewWpf2() => ViewModel = new(); +} diff --git a/src/ReactiveUI.SourceGenerators/Core/Models/HierarchyInfo.Syntax.cs b/src/ReactiveUI.SourceGenerators/Core/Models/HierarchyInfo.Syntax.cs index 66b854d..9271496 100644 --- a/src/ReactiveUI.SourceGenerators/Core/Models/HierarchyInfo.Syntax.cs +++ b/src/ReactiveUI.SourceGenerators/Core/Models/HierarchyInfo.Syntax.cs @@ -4,7 +4,6 @@ // See the LICENSE file in the project root for full license information. using System.Collections.Immutable; -using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs b/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs index 29fd476..9e42eec 100644 --- a/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs +++ b/src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs @@ -3,9 +3,6 @@ // 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; -using System.Collections.Generic; -using System.Text; using Microsoft.CodeAnalysis; using ReactiveUI.SourceGenerators.Extensions; using ReactiveUI.SourceGenerators.Helpers; @@ -22,8 +19,8 @@ internal sealed partial record TargetInfo( { public static TargetInfo From(INamedTypeSymbol namedTypeSymbol) { - var targetHintName = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); - var targetName = namedTypeSymbol.Name; + var targetHintName = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat).Replace("<", "_").Replace(">", "_"); + var targetName = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); var targetNamespace = namedTypeSymbol.ContainingNamespace.ToDisplayString(SymbolHelpers.DefaultDisplay); var targetNameWithNamespace = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); var targetAccessibility = namedTypeSymbol.GetAccessibilityString();