Skip to content

[release/6.0] Emit diagnostics & exceptions for sourcegen handling init-only properties & JsonInclude attributes #59097

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

Merged
merged 4 commits into from
Sep 15, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 14, 2021

Backport of #58993 to release/6.0

/cc @eiriktsarpalis

Customer Impact

Customer reported #58770

Source generation mode currently does not support deserializing classes with init-only properties. Furthermore, it cannot support private properties that have been marked with the JsonInclude attribute. Current behavior is to silently ignore these conditions and not deserialize the impacted properties at all. This PR

  1. Makes the source generator emit a compile-time diagnostic warning and also
  2. Changes the runtime behavior so an InvalidOperationException is thrown.

Moreover it is making a related improvement in which source generated exception messages have been moved to the project's resource strings. #58292

Testing

Testing has been added validating both the compile-time diagnostic messages and the runtime exceptions.

Risk

Low. Relatively straightforward changes to product code to account to account for init-only property and JsonInclude attribute detection.

@ghost
Copy link

ghost commented Sep 14, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #58993 to release/6.0

/cc @eiriktsarpalis

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis eiriktsarpalis self-assigned this Sep 14, 2021
@eiriktsarpalis eiriktsarpalis added this to the 6.0.0 milestone Sep 14, 2021
layomia
layomia previously approved these changes Sep 14, 2021
@steveharter
Copy link
Contributor

@eiriktsarpalis do you want to get into main first, then cherry-pick commit to this PR?

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Sep 14, 2021

@steveharter I've already cherry picked the changes in #59104

@danmoseley
Copy link
Member

@MattGal can you remind me of the telltale signature of the issue you added retries for? is this one?

❌[Log] .dotnet\sdk\6.0.100-rc.1.21411.28\NuGet.RestoreEx.targets(19,5): error : Failed to retrieve information about 'optimization.windows_nt-x86.PGO.CoreCLR' from remote source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/\_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/optimization.windows\_nt-x86.pgo.coreclr/index.json'.
at NuGet.Protocol.HttpFileSystemBasedFindPackageByIdResource.FindPackagesByIdAsync(String id, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Protocol.HttpFileSystemBasedFindPackageByIdResource.EnsurePackagesAsync(String id, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Protocol.HttpFileSystemBasedFindPackageByIdResource.DoesPackageExistAsync(String id, NuGetVersion version, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Commands.SourceRepositoryDependencyProvider.FindLibraryCoreAsync(LibraryRange libraryRange, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Commands.SourceRepositoryDependencyProvider.<>c__DisplayClass19_0.<<FindLibraryAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
...

@danmoseley
Copy link
Member

@lewing the JSON "failure" in net6.0-Browser-Release-wasm-Mono_Release-normal-Ubuntu.1804.Amd64.Open is another one where there seems to be no relevant info. What should we do in case of failures like this?

@danmoseley
Copy link
Member

Edited template to add customer reported (which helps us make decisions) and link.

@danmoseley
Copy link
Member

Approved. Fixes customer reported blocker in new generator feature. Changes are entirely limited to generator.

@danmoseley danmoseley added the Servicing-approved Approved for servicing release label Sep 15, 2021
@danmoseley danmoseley closed this Sep 15, 2021
@danmoseley danmoseley reopened this Sep 15, 2021
@danmoseley
Copy link
Member

Restarting to pick up fix for #59136

@eiriktsarpalis
Copy link
Member

We seem to have merge conflicts, I'll see if I can rebase on top of the latest release/6.0

@eiriktsarpalis eiriktsarpalis force-pushed the backport/pr-58993-to-release/6.0 branch from be8bd9f to ad0e10b Compare September 15, 2021 15:23
@MattGal
Copy link
Member

MattGal commented Sep 15, 2021

@MattGal can you remind me of the telltale signature of the issue you added retries for? is this one?

❌[Log] .dotnet\sdk\6.0.100-rc.1.21411.28\NuGet.RestoreEx.targets(19,5): error : Failed to retrieve information about 'optimization.windows_nt-x86.PGO.CoreCLR' from remote source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/\_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/optimization.windows\_nt-x86.pgo.coreclr/index.json'.
at NuGet.Protocol.HttpFileSystemBasedFindPackageByIdResource.FindPackagesByIdAsync(String id, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Protocol.HttpFileSystemBasedFindPackageByIdResource.EnsurePackagesAsync(String id, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Protocol.HttpFileSystemBasedFindPackageByIdResource.DoesPackageExistAsync(String id, NuGetVersion version, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Commands.SourceRepositoryDependencyProvider.FindLibraryCoreAsync(LibraryRange libraryRange, SourceCacheContext cacheContext, ILogger logger, CancellationToken cancellationToken)
at NuGet.Commands.SourceRepositoryDependencyProvider.<>c__DisplayClass19_0.<<FindLibraryAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
...

Yes, this looks like it's cut off from the specific error message but otherwise it looks like that problem and an 8/11 SDK would not have the change (the first, IIRC, was 6.0.100-rc.1.21430.12), from 8/30. Eventually I'd assume the 6.0 branch will have newer 6.0 SDK, but it may need also need an arcade update or a cherry pick of where I initially set the variables directly in runtime

@danmoseley
Copy link
Member

Yes, this looks like it's cut off from the specific error message but otherwise it looks like that problem and an 8/11 SDK would not have the change (the first, IIRC, was 6.0.100-rc.1.21430.12), from 8/30. Eventually I'd assume the 6.0 branch will have newer 6.0 SDK, but it may need also need an arcade update or a cherry pick of where I initially set the variables directly in runtime

@ViktorHofer thoughts about picking up Matt's fix in release/6.0? It seems proven now in main and we'll be servicing out of 6.0 for years.

@ViktorHofer
Copy link
Member

@ViktorHofer thoughts about picking up Matt's fix in release/6.0? It seems proven now in main and we'll be servicing out of 6.0 for years.

Absolutely. e72aafc was merged earlier today which includes Matt's fix.

@MattGal
Copy link
Member

MattGal commented Sep 15, 2021

@ViktorHofer thoughts about picking up Matt's fix in release/6.0? It seems proven now in main and we'll be servicing out of 6.0 for years.

Absolutely. e72aafc was merged earlier today which includes Matt's fix.

Was typing similar. I think no more actions needed though once you have arcade updates you could remove the variables from your common .yml place (that was for before Arcade was updated)

@danmoseley
Copy link
Member

Oh great, I just missed it here then.

@Anipik Anipik merged commit 0bc0c0a into release/6.0 Sep 15, 2021
@Anipik Anipik deleted the backport/pr-58993-to-release/6.0 branch September 15, 2021 22:03
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants