You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ConfigurationBinder source generator emits SYSLIB1100 when it shouldn't apply #93132
I have a public type with an internal constructor in the same assembly as my bind call.
a. I wouldn't expect the source generator to need to construct the object at all since it's a Bind call.
b. The constructor is internal, which makes it visible to the source generator.
I see a lot of folks hitting SYSLIB1100 and SYSLIB1101 for non-root level types - these behave similar to a root level type that's being passed to Bind -- the binder doesn't always need to create a type so the fact that it cannot may not be a worthwhile diagnostic to raise to the user.
This problem is exacerbated by lack of the ability to granularly suppress these warnings - or suppress at all in source due to #92509.
I wonder if we should split these diagnostics into two - one set where it's clear that we can't do what the user wanted and another where it's more informational (and not a warning). @tarekgh@eiriktsarpalis@eerhardt
On the flip side of that - we still end up generating a ton of binding code for members that ultimately might never show up in configuration - take the case where someone had a Func hanging off the configuration type and we end up producing bind logic for a good amount of reflection types.
I think we might want something like JsonIgnore here, but use it to prevent us from generating bind logic. We already have ConfigurationKeyNameAttribute which can set the name of member, but not attribute to exclude a member. For the runtime binder this might not matter - but for the source gen it's more important.
the binder doesn't always need to create a type so the fact that it cannot may not be a worthwhile diagnostic to raise to the user.
Guessing that depends on whether the type is present in a nested property or not?
Even if the binder did need the constructor, is this a valid diagnostic to raise given that the internal constructor is being used regardless? I would only have expected this to complain only if the constructor were inaccessible to the generator.
What I was discussing above is even broader than the original issue. The internal constructor problem is a plain-old-bug but one that will may be moot if we take the broader look at this behavior.
My point is that binding to types which are not constructable is actually a very common scenario and doesn't warrant raising a warning.
Activity
ericstj commentedon Oct 27, 2023
I see a lot of folks hitting
SYSLIB1100andSYSLIB1101for non-root level types - these behave similar to a root level type that's being passed toBind-- the binder doesn't always need to create a type so the fact that it cannot may not be a worthwhile diagnostic to raise to the user.This problem is exacerbated by lack of the ability to granularly suppress these warnings - or suppress at all in source due to #92509.
I wonder if we should split these diagnostics into two - one set where it's clear that we can't do what the user wanted and another where it's more informational (and not a warning). @tarekgh @eiriktsarpalis @eerhardt
On the flip side of that - we still end up generating a ton of binding code for members that ultimately might never show up in configuration - take the case where someone had a Func hanging off the configuration type and we end up producing bind logic for a good amount of reflection types.
I think we might want something like
JsonIgnorehere, but use it to prevent us from generating bind logic. We already haveConfigurationKeyNameAttributewhich can set the name of member, but not attribute to exclude a member. For the runtime binder this might not matter - but for the source gen it's more important.eiriktsarpalis commentedon Oct 27, 2023
Guessing that depends on whether the type is present in a nested property or not?
Even if the binder did need the constructor, is this a valid diagnostic to raise given that the internal constructor is being used regardless? I would only have expected this to complain only if the constructor were inaccessible to the generator.
ericstj commentedon Oct 27, 2023
What I was discussing above is even broader than the original issue. The internal constructor problem is a plain-old-bug but one that will may be moot if we take the broader look at this behavior.
My point is that binding to types which are not constructable is actually a very common scenario and doesn't warrant raising a warning.
ericstj commentedon Aug 6, 2024
Repro in this issue no longer produces a warning. We also fixed our behavior for unsupported types in
27685cf
agocke commentedon Mar 26, 2026
@ericstj Azure SDK/MCP is still seeing this warning (and others) in Microsoft.Identity.Abstractions: https://github.com/anuchandy/idweb-source-gen-warns. Any idea what could be going on here, and how we could suppress generation/warnings for these members?
svick commentedon Mar 30, 2026
@agocke I think marking the property as
[ConfigurationIgnore]should fix that, if and when that becomes available. See #125111.