Describe the bug 🐞
When the [Reactive] attribute is used on a partial property inside a partial class, if you add a JsonPropertyName attribute, it is copied in the generated partial class code and the compilation fails with :
Duplicate 'global::System.Text.Json.Serialization.JsonPropertyNameAttribute' attribute
Step to reproduce
Create the following class:
public partial class MyClass : ReactiveObject
{
[Reactive]
[JsonPropertyName("test")]
public partial string MyProperty { get; set; }
}
And go to the generated partial class, you will see the same attribute generated:
public partial class MyClass
{
[global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveGenerator", "2.2.0.0")]
private string _myProperty;
/// <inheritdoc cref="_myProperty"/>
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.Text.Json.Serialization.JsonPropertyNameAttribute("test")]
public partial string MyProperty
{
get => _myProperty;
[global::System.Diagnostics.CodeAnalysis.MemberNotNull("_myProperty")]
set => this.RaiseAndSetIfChanged(ref _myProperty, value);
}
}
Then, the project does not compile
Reproduction repository
https://github.com/reactiveui/ReactiveUI
Expected behavior
The attribute should not be re-generated.
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows 11
Version
2.2.4
Device
No response
ReactiveUI Version
20.3.1
Additional information ℹ️
It was working fine with version 2.1.27
Describe the bug 🐞
When the
[Reactive]attribute is used on a partial property inside a partial class, if you add a JsonPropertyName attribute, it is copied in the generated partial class code and the compilation fails with :Duplicate 'global::System.Text.Json.Serialization.JsonPropertyNameAttribute' attributeStep to reproduce
Create the following class:
And go to the generated partial class, you will see the same attribute generated:
Then, the project does not compile
Reproduction repository
https://github.com/reactiveui/ReactiveUI
Expected behavior
The attribute should not be re-generated.
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows 11
Version
2.2.4
Device
No response
ReactiveUI Version
20.3.1
Additional information ℹ️
It was working fine with version 2.1.27