DependencyPropertyGenerator icon indicating copy to clipboard operation
DependencyPropertyGenerator copied to clipboard

Using `RoutedEvent<T>` with custom event args type results in two `global::` declarations

Open otomad opened this issue 1 year ago • 0 comments

Describe the bug

Using RoutedEvent<T> with custom routed event args type results in two global:: declarations, this will cause a compilation error.

Steps to reproduce the bug

Declare a RoutedEvent<T> with custom event args type like this:

[RoutedEvent<RoutedEventArgs>("Click", RoutedEventStrategy.Bubble)]

This will generate code like this:

[global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "1.4.0.0")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public event global::global::System.Windows.RoutedEventArgs Click
{
    add => AddHandler(ClickEvent, value);
    remove => RemoveHandler(ClickEvent, value);
}

As you can see, the type name of the generated event contains two global:: declarations, which will cause a compilation error. global::global::System.Windows.RoutedEventArgs

Expected behavior

Just need one "global::" declaration, get rid of the redundant, like this:

global::System.Windows.RoutedEventArgs

[global::System.CodeDom.Compiler.GeneratedCode("DependencyPropertyGenerator", "1.4.0.0")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public event global::System.Windows.RoutedEventArgs Click
{
    add => AddHandler(ClickEvent, value);
    remove => RemoveHandler(ClickEvent, value);
}

Screenshots

image

NuGet package version

1.4.0

IDE

Visual Studio 2022

Additional context

No response

otomad avatar Oct 04 '24 17:10 otomad