Skip to content

Commit

Permalink
Added null check for property
Browse files Browse the repository at this point in the history
  • Loading branch information
brnleehng committed May 12, 2016
1 parent 374455a commit dcdca06
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,14 @@ private static bool ShouldValidate(this IType model)
/// 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>
/// <returns>A reference to the property documentation</returns>
public static string GetFormattedPropertyDocumentation(this Property property)
{
if (property == null)
{
throw new ArgumentNullException("property");
}

if (string.IsNullOrEmpty(property.Documentation))
{
return property.Documentation.EscapeXmlComment();
Expand All @@ -149,13 +154,13 @@ public static string GetFormattedPropertyDocumentation(this Property property)
string firstWord = property.Documentation.TrimStart().Split(' ').First();
if (firstWord.Length <= 1)
{
documentation += char.ToLower(property.Documentation[0]) + property.Documentation.Substring(1);
documentation += char.ToLower(property.Documentation[0], CultureInfo.InvariantCulture) + property.Documentation.Substring(1);
}
else
{
documentation += firstWord.ToUpper() == firstWord
documentation += firstWord.ToUpper(CultureInfo.InvariantCulture) == firstWord
? property.Documentation
: char.ToLower(property.Documentation[0]) + property.Documentation.Substring(1);
: char.ToLower(property.Documentation[0], CultureInfo.InvariantCulture) + property.Documentation.Substring(1);
}

return documentation.EscapeXmlComment();
Expand Down

0 comments on commit dcdca06

Please sign in to comment.