Skip to content

Commit 954ab78

Browse files
authored
Fix For Generators used on Generic class (#119)
1 parent 5b65578 commit 954ab78

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved.
2+
// Licensed to the .NET Foundation under one or more agreements.
3+
// The .NET Foundation licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using ReactiveUI;
7+
using ReactiveUI.SourceGenerators;
8+
9+
namespace SGReactiveUI.SourceGenerators.Test;
10+
11+
/// <summary>
12+
/// TestViewModel2.
13+
/// </summary>
14+
/// <typeparam name="T">the type.</typeparam>
15+
/// <seealso cref="ReactiveUI.ReactiveObject" />
16+
public partial class TestViewModel2<T> : ReactiveObject
17+
{
18+
[Reactive]
19+
private bool _IsTrue;
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) 2024 .NET Foundation and Contributors. All rights reserved.
2+
// Licensed to the .NET Foundation under one or more agreements.
3+
// The .NET Foundation licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using System.Windows;
7+
using ReactiveUI.SourceGenerators;
8+
9+
namespace SGReactiveUI.SourceGenerators.Test;
10+
11+
/// <summary>
12+
/// TestViewWpf2.
13+
/// </summary>
14+
/// <seealso cref="System.Windows.Window" />
15+
[IViewFor("TestViewModel2<int>")]
16+
public partial class TestViewWpf2 : Window
17+
{
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="TestViewWpf2"/> class.
20+
/// </summary>
21+
public TestViewWpf2() => ViewModel = new();
22+
}

src/ReactiveUI.SourceGenerators/Core/Models/HierarchyInfo.Syntax.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// See the LICENSE file in the project root for full license information.
55

66
using System.Collections.Immutable;
7-
using System.Linq;
87
using Microsoft.CodeAnalysis;
98
using Microsoft.CodeAnalysis.CSharp;
109
using Microsoft.CodeAnalysis.CSharp.Syntax;

src/ReactiveUI.SourceGenerators/Core/Models/TargetInfo.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using System;
7-
using System.Collections.Generic;
8-
using System.Text;
96
using Microsoft.CodeAnalysis;
107
using ReactiveUI.SourceGenerators.Extensions;
118
using ReactiveUI.SourceGenerators.Helpers;
@@ -22,8 +19,8 @@ internal sealed partial record TargetInfo(
2219
{
2320
public static TargetInfo From(INamedTypeSymbol namedTypeSymbol)
2421
{
25-
var targetHintName = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
26-
var targetName = namedTypeSymbol.Name;
22+
var targetHintName = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat).Replace("<", "_").Replace(">", "_");
23+
var targetName = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
2724
var targetNamespace = namedTypeSymbol.ContainingNamespace.ToDisplayString(SymbolHelpers.DefaultDisplay);
2825
var targetNameWithNamespace = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
2926
var targetAccessibility = namedTypeSymbol.GetAccessibilityString();

0 commit comments

Comments
 (0)