Open eerhardt opened 1 year ago
Tagging subscribers to this area: @dotnet/area-extensions-configuration See info in area-owners.md if you want to be subscribed.
Author: | eerhardt |
---|---|
Assignees: | - |
Labels: | `area-Extensions-Configuration` |
Milestone: | - |
I thought this might be type conversion issue but it looks a simple enough fixing it by casting the int
to the enum ServiceVersion
The enum bug is already fixed with https://github.com/dotnet/runtime/pull/93160 which we'll backport in https://github.com/dotnet/runtime/pull/94070.
This issue is tracking the fact that we generate a InitializeBlobClientOptions
method but never call it.
I was able to isolate that repro down to the case where we only ever Bind
to a type and that type has a constructor initialization strategy. Since the generator only produces Bind
logic (and not Get
) it never calls the initialization method.
Simplified repro: bindCtor.zip
Expect: All methods generated are necessary Actual: InitializeMyConfig is generated but never called.
In fixing this we should see if there's a way to make the unreachable code analyzer catch this sort of thing on our generated code - at least in our tests.
Description
When trying to use the ConfigurationBinder source generator with the Azure SDK's ClientOptions objects I'm getting compile errors. However, the compile errors come from a method that isn't even invoked.
Reproduction Steps
(note the alias, global usings, and empty namespace is to work around #93498 and #94065
Expected behavior
The source generator should work for these options types. The Azure SDK currently uses the reflection-based config binder here:
https://github.com/Azure/azure-sdk-for-net/blob/6d43c499a7cd6bf6b1aba9ea220ba22e54e6f7e1/sdk/extensions/Microsoft.Extensions.Azure/src/AzureClientBuilderExtensions.cs#L83
Actual behavior
You get a build error:
This is coming from this generated code:
However, this
InitializeBlobClientOptions
method isn't even called.Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response