Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Azure.ETagConverter is internal, blocks using System.Text.Json source gen to deserialize objects #35201

Open
stephenjust opened this issue Mar 28, 2023 · 8 comments
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Milestone

Comments

@stephenjust
Copy link
Contributor

stephenjust commented Mar 28, 2023

Library name and version

Azure.Core 1.28.0

Describe the bug

System.Text.Json's source generators attempt to reference Azure.ETagConverter when you use source generators to create a JsonSerializerContext.

Making Azure.ETagConverter public instead of internal should resolve this issue.

Expected behavior

Azure.ETagConverter should be accessible so that Source Generators create valid code.

Actual behavior

Error CS0122 'ETagConverter' is inaccessible due to its protection level FirewallService System.Text.Json.SourceGeneration\System.Text.Json.SourceGeneration.JsonSourceGenerator\NetworkSecurityGroupTemplateSerializerContext.ETag.g.cs 25 Active

Reproduction Steps

Create a source generator class on .net 6.0 with System.Text.Json 6.0.0:

 [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
 [JsonSerializable(typeof(SecurityRuleData))]
 internal partial class SecurityRuleDataSerializerContext : JsonSerializerContext
 {
 }

On build, the build will fail due to the reference to Azure.ETagConverter in the generated output.

(This also occurs if you were to include a property of type SecurityRuleData inside some other class. that had a JsonSerializerContext created for it.)

Environment

.NET SDK:
Version: 7.0.202
Commit: 6c74320bc3

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22624
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.202\

Host:
Version: 7.0.4
Architecture: x64
Commit: 0a396acafe

.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.407 [C:\Program Files\dotnet\sdk]
5.0.416 [C:\Program Files\dotnet\sdk]
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.301 [C:\Program Files\dotnet\sdk]
7.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 28, 2023
@jsquire jsquire self-assigned this Mar 29, 2023
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. Azure.Core customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 29, 2023
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 29, 2023
@jsquire
Copy link
Member

jsquire commented Mar 29, 2023

Hi @stephenjust. Thank you for reaching out and we regret that you're experiencing difficulties. Can you provide a bit more context to help me understand the end-to-end scenario for what you're trying to accomplish?

@jsquire jsquire added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Mar 29, 2023
@github-actions
Copy link

Hi @stephenjust. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

Hi @stephenjust, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label Apr 5, 2023
@stephenjust
Copy link
Contributor Author

We want to enable trimming on our dotnet application that works with ARM models. Reflection based serializers are not supported in trimmed applications, so we tried to use a source generator based serializer. However, the system.text.json source generator does not work on these nuget packages because of their use of an internal converter.

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. labels Apr 5, 2023
@jsquire jsquire removed their assignment Apr 5, 2023
@jsquire jsquire added feature-request This issue requires a new behavior in the product in order be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Apr 5, 2023
@jsquire jsquire added this to the Backlog milestone Apr 5, 2023
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Apr 5, 2023
@jsquire
Copy link
Member

jsquire commented Apr 5, 2023

@jsquire
Copy link
Member

jsquire commented Apr 5, 2023

Thank you for the additional context, @stephenjust. I've looped in some folks for discussion.

@annelo-msft
Copy link
Member

Adding @m-nash, who is working on serialization for .NET Azure SDK libraries.

@fleed
Copy link

fleed commented Jan 24, 2025

Run into the same problem almost 2 years later. Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
None yet
Development

No branches or pull requests

4 participants