basilisque-framework / AutoImplementer

Automatically implements interfaces
Apache License 2.0
1 stars 1 forks source link

Suggestion: Attribute for declaring required fields #2

Closed Fasteroid closed 1 week ago

Fasteroid commented 2 weeks ago

Unfortunately, C# does not currently allow this syntax:

public interface IAmSad {
    required int WhyNot
}

This means devs can't declare required fields on classes using this code generator (yet). How sad.

However, I bet this limitation could easily be worked around by introducing an attribute that this generator could look for:

public interface IAmSad {
    [Required] int WhyNot { get; set; }
}

Might PR this too

astaerk commented 2 weeks ago

Yeah, I also thought about that last week. Will look into your PR. Thank you!