Skip to content

Exclude properties of delegate types in configuration source generator #94117

Closed

Description

@tarekgh

Presently, the configuration source generator generates binding code for properties employing delegate, Func, or Action types. However, there is no means to bind configuration to such types. Consequently, the generator generates an abundance of code for all types associated with these delegates, many of which will not be utilized and may lead to code that does not compile. Here's an example:

https://github.com/dotnet/extensions/blob/14943b99572078f1bcf2c51e9507cf2631133fae/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/FailureEventMetricsOptions.cs#L11

This issue is tracking to fix the source generator to skip generating any code for such properties or types.

Activity

  1. ghost added
    untriaged
    on Oct 27, 2023
  2. added this to the 9.0.0 milestone on Oct 27, 2023
  3. ghost removed
    untriaged
    on Oct 27, 2023
  4. added
    untriaged
    source-generator
    and removed
    untriaged
    on Oct 27, 2023
  5. tarekgh commented on Oct 27, 2023

    @tarekgh
    MemberAuthor
  6. ghost added
    in-pr
    on Oct 27, 2023
  7. ghost removed
    in-pr
    on Oct 28, 2023
  8. ericstj commented on Oct 28, 2023

    @ericstj
    Member

    We should match the exclusions used by JSON: https://github.com/dotnet/runtime/blob/9461f4b5bd036005f37e78516c48b13396f76750/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs#L1687C26-L1687C43

    • SerializationInfo
    • IntPtr / UIntPtr
    • MemberInfo and derived types
    • Delegate and derived type
    • multi-dimensional arrays (already excluded)

    These need to be excluded wherever they occur in the object graph including nullable, array, and collection members. They are OK to appear as generic parameters -- but should be excluded when appearing as members in such types.

  9. changed the title [-]Exclude options properties of delegate types in configuration source generator[/-] [+]Exclude properties of delegate types in configuration source generator[/+] on Oct 28, 2023
  10. ghost added
    in-pr
    on Nov 9, 2023
  11. ghost removed
    in-pr
    on Nov 10, 2023
  12. tarekgh commented on Nov 10, 2023

    @tarekgh
    MemberAuthor

    This is now is completed.

  13. locked and limited conversation to collaborators on Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Extensions-Configurationsource-generator

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions