Skip to content

Forwarded attributes can crash generator when accessing invalid members #683

Closed

Description

@Sergio0694

Describe the bug

The forwarded attribute logic (for both observable properties and relay commands) can crash the generator in some invalid scenarios. We should instead emit a proper diagnostic and gracefully skip the current attribute, rather than crashing the generator.

Steps to reproduce

public partial class Foo : ObservableObject
{
    [ObservableProperty]
    [property: Test(TestAttribute.M)]
    private int number;
}

public class TestAttribute : Attribute
{
    public static string M => "";
}

Expected behavior

This should skip the attribute and generate a diagnostic.

Activity

  1. added
    bug 🐛An unexpected issue that highlights incorrect behavior
    on May 7, 2023
  2. moved this to 🏗 In progress in 8.2.1on May 7, 2023
  3. moved this from 🏗 In progress to ✅ Done in 8.2.1on Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behaviormvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions