Skip to content

Commit

Permalink
Updated comments for references
Browse files Browse the repository at this point in the history
  • Loading branch information
brnleehng committed May 12, 2016
1 parent e1d41ab commit 78356b5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@ private static bool ShouldValidate(this IType model)
return false;
}

/// <summary>
/// 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.
/// </summary>
/// <param name="property">The given property documentation to format</param>
/// <returns>A reference of the property documentation</returns>
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();
}

/// <summary>
/// Format the value of a sequence given the modeled element format. Note that only sequences of strings are supported
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace @(Settings.Namespace).Models
@foreach (var property in Model.PropertyTemplateModels.Where(p => !p.IsConstant))
{
@:/// <summary>
@:@WrapComment("/// ", property.Documentation.EscapeXmlComment())
@:@WrapComment("/// ", property.GetFormattedPropertyDocumentation())
@:/// </summary>
if (property.Type.IsPrimaryType(KnownPrimaryType.Date))
{
Expand Down

0 comments on commit 78356b5

Please sign in to comment.