Skip to content

ObservableProperty source generator does not output new keyword for partial auto-properties #1013

@rabuckley

Description

@rabuckley

Describe the bug

The ObservableProperty source generator does not copy new keywords from declaration into the outputted code for partial auto-properties.

Regression

No.

Steps to reproduce

using CommunityToolkit.Mvvm.ComponentModel;

public abstract partial class MyClass : ObservableObject
{
    public string MyProperty { get; set; } = string.Empty;
}

public sealed partial class MyDerivedClass : MyClass
{
    [ObservableProperty]
    public new partial int MyProperty { get; private set; }
}

Produces this compilation error

MyDerivedClass.g.cs(10,24): error CS8800: Both partial member declarations must have identical combinations of 'virtual', 'override', 'sealed', and 'new' modifiers.

Expected behavior

Not produce compilation errors by outputting the new keyword.

Screenshots

No response

IDE and version

Other

IDE version

N/A

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.4.0-preview3

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzer 👓A new analyzer being implemented or updatedmvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions