Skip to content

Commit

Permalink
Update storage generator to suppress FxCop issues (Azure#17181)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored and annelo-msft committed Feb 17, 2021
1 parent 8cdf112 commit d0f7248
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -902,12 +902,17 @@ function generateObject(w: IndentWriter, model: IServiceModel, type: IObjectType
w.line(`/// <summary>`);
w.line(`/// ${property.description || property.model.description || property.name}`);
w.line(`/// </summary>`);
let internalSetter = !property.isNullable && (property.readonly || property.model.type === `array`);
let isCollection = isPrimitiveType(property.model) && property.model.itemType && !type.struct;
if (property.model.type === `byte`) {
w.line(`#pragma warning disable CA1819 // Properties should not return arrays`);
}
if (isCollection && !internalSetter) {
w.line(`#pragma warning disable CA2227 // Collection properties should be readonly`);
}
w.write(`public ${types.getDeclarationType(property.model, property.required, property.readonly)} ${naming.property(property.clientName)} { get; `);
if (!type.struct) {
if (!property.isNullable && (property.readonly || property.model.type === `array`)) {
if (internalSetter) {
w.write(`internal `);
}
w.write(`set; `);
Expand All @@ -917,6 +922,9 @@ function generateObject(w: IndentWriter, model: IServiceModel, type: IObjectType
if (property.model.type === `byte`) {
w.line(`#pragma warning restore CA1819 // Properties should not return arrays`);
}
if (isCollection && !internalSetter) {
w.line(`#pragma warning restore CA2227 // Collection properties should be readonly`);
}
}

// Instantiate nested models if necessary
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d0f7248

Please sign in to comment.