fix: suppress warnings on enumeration of deprecated fields - #990
fix: suppress warnings on enumeration of deprecated fields#990robertvoinescu-work wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for disabling obsolete warnings on properties generated for deprecated response resource fields in paginated methods. It adds extension methods to PropertyDeclarationSyntax for handling pragma warnings, tracks whether a response resource field is deprecated in MethodDetails, and applies the pragma warning disable in ServiceCodeGenerator. The feedback suggests breaking down a long statement in ServiceCodeGenerator.cs into a local variable to improve readability.
| var propertyName = method.ResourcesFieldName; | ||
| var genericGetEnumerator = Method(Public, ctx.Type(Typ.Generic(typeof(IEnumerator<>), method.ResourceTyp)), "GetEnumerator")() | ||
| .WithBody(Property(Public, ctx.TypeDontCare, propertyName).Call(nameof(IEnumerable<int>.GetEnumerator))()) | ||
| .WithBody(Property(Public, ctx.TypeDontCare, propertyName).MaybeWithPragmaDisableObsoleteWarning(method.ResponseResourceFieldIsDeprecated).Call(nameof(IEnumerable<int>.GetEnumerator))()) |
There was a problem hiding this comment.
The statement for genericGetEnumerator is extremely long (exceeding 180 characters) and hard to read. Breaking it down by introducing a local variable for the property expression significantly improves readability and maintainability.
var propertyName = method.ResourcesFieldName;
var property = Property(Public, ctx.TypeDontCare, propertyName)
.MaybeWithPragmaDisableObsoleteWarning(method.ResponseResourceFieldIsDeprecated);
var genericGetEnumerator = Method(Public, ctx.Type(Typ.Generic(typeof(IEnumerator<>), method.ResourceTyp)), "GetEnumerator")()
.WithBody(property.Call(nameof(IEnumerable<int>.GetEnumerator))())
amanda-tarafa
left a comment
There was a problem hiding this comment.
Please add tests for this.
b/543020713