Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "gets or sets" rule for the model template in the CSharp code generator #989

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions AutoRest/Generators/CSharp/CSharp/ClientModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ private static bool ShouldValidate(this IType model)
/// </summary>
/// <param name="property">The given property documentation to format</param>
/// <returns></returns>
public static string GetFormattedPropertyDocumentation(PropertyTemplateModel property)
public static string GetFormattedPropertyDocumentation(Property property)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this an extension method like the other methods in this file? That way you can just call property.GetFormattedPropertyDocumentation()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay will make this change

{
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(PropertyTemplateModel pro
string firstWord = property.Documentation.Split(' ').First();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you trim the start of the Documetation to ensure there aren't any leading spaces?

Copy link
Contributor Author

@brnleehng brnleehng May 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'll make that change

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
? 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