-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Report error when generating serializer for model from ref assembly #9520
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
Conversation
public const string Category = "Usage"; | ||
|
||
private static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor( | ||
RuleId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should make this an error, since it is most likely going to break something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to error
{ | ||
public const string RuleId = DiagnosticRuleId.ReferenceAssemblyWithGenerateSerializer; | ||
public const string Title = "[GenerateSerializer] used in a reference assembly"; | ||
public const string MessageFormat = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps MessageFormat & Description need to be swapped, essentially, so that the description includes the detail and message format only includes the top line "The type {0} is marked with [GenerateSerializer] in a reference assembly"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swapped. let me know if you think this is fine
We suspect inability to serialize private fields because of the ref assembly. Therefore I am adding a check on code generator, which will emit a diagnostic if the target model is coming from the ref assembly.
Also moved ruleIds to separate file to easily nagivate accross different existing diagnosticIds.
Example:

Fixes #9265
Microsoft Reviewers: Open in CodeFlow