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

Show Deserializaton Errors from Source Generator #572

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

christianhelle
Copy link
Owner

@christianhelle christianhelle commented Dec 19, 2024

This resolves #568 which relates to #534

This pull request includes several changes to the RefitterSourceGenerator.cs file to improve error handling and diagnostics during the code generation process. The most important changes include adding a diagnostics parameter to the TryDeserialize method and enhancing the error handling mechanism.

Improvements to error handling and diagnostics:

Using the source generator with a .refitter file containing invalid JSON will result in an error message like this:

CSC : error REFITTER000: 
Unable to deserialize .refitter file: System.Text.Json.JsonException
The JSON object contains a trailing comma at the end which is not supported in this mode. 
Change the reader options. Path: $ | LineNumber: 8 | BytePositionInLine: 0.

Build failed with 1 error(s) in 2.3s

@christianhelle christianhelle added enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code labels Dec 19, 2024
@christianhelle christianhelle self-assigned this Dec 19, 2024
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.09%. Comparing base (ff76e06) to head (88dea30).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #572      +/-   ##
==========================================
- Coverage   94.90%   92.09%   -2.82%     
==========================================
  Files          53       53              
  Lines        2612     2731     +119     
==========================================
+ Hits         2479     2515      +36     
- Misses         98      181      +83     
  Partials       35       35              
Flag Coverage Δ
unittests 92.09% <ø> (-2.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@christianhelle christianhelle merged commit d511a0b into main Dec 19, 2024
9 of 10 checks passed
@christianhelle christianhelle deleted the source-generator-error-reporting branch December 19, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source generator errors are hidden
1 participant