Skip to content

ConfigurationBinder source generator should not generate source for types without members #94142

Open
@ericstj

Description

@ericstj

If a type contains no members for binding we shouldn't generator source for that. This includes the case where the only members it generates are references to itself.

Consider the following types:

public abstract class MySingleton
{
    public static MySingleton Instance {get; set;}
}
public abstract class MyNode
{
  public MyNode Next { get; set; }
}
public class MyClass
{
   // all members below are excluded
  public int[,] Matrix { get; set; }
  public Func<string, int> ParseMethod { get; set; }
}

All have no bindable members and result in useless code gen today. It's harmless - but we should try to identify these types of things through heuristics to reduce the size of the codegen. We should inform the behavior for non-abstract instance types from the runtime binder to determine if they'll be initialized or not in these cases -- I don't think they would.

Metadata

Metadata

Assignees

Labels

area-Extensions-ConfigurationenhancementProduct code improvement that does NOT require public API changes/additionssource-generatorIndicates an issue with a source generator feature

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions