-
Notifications
You must be signed in to change notification settings - Fork 366
Closed
Labels
bug 🐛An unexpected issue that highlights incorrect behaviorAn unexpected issue that highlights incorrect behaviormvvm-toolkit 🧰Issues/PRs for the MVVM ToolkitIssues/PRs for the MVVM Toolkit
Description
Describe the bug
Observable Property used on a field with an escaped name (the name starting with the @ sign such as @event @param @int) is not generating correctly.
Steps to reproduce
- Create a project with the MVVM Toolkit installed
- Add in this code snippet
[ObservableProperty]
double @event;- Type
Eventsomewhere in a method andCtrl + Clickit to go to the definition - The output should look like this
/// <inheritdoc cref="event"/>
[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", "8.2.0.0")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public double Event
{
get => event;
set
{
if (!global::System.Collections.Generic.EqualityComparer<double>.Default.Equals(event, value))
{
OnEventChanging(value);
OnEventChanging(default, value);
OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.Event);
event = value;
OnEventChanged(value);
OnEventChanged(default, value);
OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.Event);
}
}
}Expected behavior
Every single event in the generated code should be replaced with @event because event is treated as a C# keyword.
/// <inheritdoc cref="@event"/>
[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", "8.2.0.0")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public double Event
{
get => @event;
set
{
if (!global::System.Collections.Generic.EqualityComparer<double>.Default.Equals(@event, value))
{
OnEventChanging(value);
OnEventChanging(default, value);
OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.Event);
@event = value;
OnEventChanged(value);
OnEventChanged(default, value);
OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.Event);
}
}
}Screenshots
IDE and version
VS 2022
IDE version
17.6.2
Nuget packages
- CommunityToolkit.Common
- CommunityToolkit.Diagnostics
- CommunityToolkit.HighPerformance
- CommunityToolkit.Mvvm (aka MVVM Toolkit)
Nuget package version(s)
8.2.0
Help us help you
No, just wanted to report this
Metadata
Metadata
Assignees
Labels
bug 🐛An unexpected issue that highlights incorrect behaviorAn unexpected issue that highlights incorrect behaviormvvm-toolkit 🧰Issues/PRs for the MVVM ToolkitIssues/PRs for the MVVM Toolkit
