diff --git a/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs b/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs index ae4d9f11159de..ff5f118022781 100644 --- a/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs +++ b/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs @@ -131,6 +131,36 @@ private static bool ShouldValidate(this IType model) return false; } + /// + /// Format the documentation of a property properly with the correct getters and setters. Note that this validation will + /// checks for special cases such as acronyms and article words. + /// + /// The given property documentation to format + /// A reference of the property documentation + public static string GetFormattedPropertyDocumentation(this Property property) + { + if (string.IsNullOrEmpty(property.Documentation)) + { + return property.Documentation.EscapeXmlComment(); + } + + string documentation = property.IsReadOnly ? "Gets " : "Gets or sets "; + + string firstWord = property.Documentation.TrimStart().Split(' ').First(); + if (firstWord.Length <= 1) + { + documentation += char.ToLower(property.Documentation[0]) + property.Documentation.Substring(1); + } + else + { + documentation += firstWord.ToUpper() == firstWord + ? property.Documentation + : char.ToLower(property.Documentation[0]) + property.Documentation.Substring(1); + } + + return documentation.EscapeXmlComment(); + } + /// /// Format the value of a sequence given the modeled element format. Note that only sequences of strings are supported /// diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/ModelTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/ModelTemplate.cshtml index 942e67ef809e3..aeb27d92a4579 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/ModelTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/ModelTemplate.cshtml @@ -109,7 +109,7 @@ namespace @(Settings.Namespace).Models @foreach (var property in Model.PropertyTemplateModels.Where(p => !p.IsConstant)) { @:/// - @:@WrapComment("/// ", property.Documentation.EscapeXmlComment()) + @:@WrapComment("/// ", property.GetFormattedPropertyDocumentation()) @:/// if (property.Type.IsPrimaryType(KnownPrimaryType.Date)) {