From dcdca06144c0f40fcda7e3cbc7a983b17e805c57 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 12 May 2016 15:36:40 -0700 Subject: [PATCH] Added null check for property --- .../CSharp/CSharp/ClientModelExtensions.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs b/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs index ff5f11802278..028322670e58 100644 --- a/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs +++ b/AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs @@ -136,9 +136,14 @@ private static bool ShouldValidate(this IType model) /// checks for special cases such as acronyms and article words. /// /// The given property documentation to format - /// A reference of the property documentation + /// A reference to the property documentation public static string GetFormattedPropertyDocumentation(this Property property) { + if (property == null) + { + throw new ArgumentNullException("property"); + } + if (string.IsNullOrEmpty(property.Documentation)) { return property.Documentation.EscapeXmlComment(); @@ -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();