-
-
Notifications
You must be signed in to change notification settings - Fork 186
Why does TemplatesCiclo.List include values from all subclasses of Templates when using Ardalis.SmartEnum? #562
Copy link
Copy link
Open
Description
I’m using [Ardalis.SmartEnum](https://github.com/ardalis/SmartEnum) to model a base enum class and two derived enums:
public abstract class Templates : SmartEnum<Templates> { … }
public class TemplatesCiclo : Templates
{
public static readonly TemplatesCiclo IdentificadorPedido = new(1, nameof(IdentificadorPedido));
// … other members …
}
public class TemplatesNotaFiscal : Templates
{
public static readonly TemplatesNotaFiscal ValorNota = new(9, nameof(ValorNota));
// … other members …
}When I iterate over TemplatesCiclo.List, I expected only the TemplatesCiclo instances, but I also get the TemplatesNotaFiscal values:
foreach (var tmpl in TemplatesCiclo.List)
{
Console.WriteLine(tmpl.Name);
// Prints both Ciclo members AND NotaFiscal members…
}- What is causing the child class’s
Listproperty to return every instance of the base class (including those from other subclasses)? - How can I restrict the list so that it only contains the instances defined in
TemplatesCiclo?
Any insights into how SmartEnum registers and filters its static instances would be greatly appreciated!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels