-
Notifications
You must be signed in to change notification settings - Fork 202
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
Remove stringify from primitive types #5616
Open
shemogumbe
wants to merge
7
commits into
main
Choose a base branch
from
shem/remove_stringify_primitive_types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed8cf85
Remove stringify from primitive types
shemogumbe 7b65a27
clean up code
shemogumbe f43e99a
Merge branch 'main' into shem/remove_stringify_primitive_types
shemogumbe 9b378b0
revert changes in launch.json file
shemogumbe 2d3f071
Merge branch 'shem/remove_stringify_primitive_types' of https://githu…
shemogumbe 64aa774
Updated changelog"
shemogumbe 35b68a0
Merge branch 'main' into shem/remove_stringify_primitive_types
shemogumbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
var requestParams = new RequestParams(requestBodyParam, requestConfigParam, requestContentType); | ||
if (!codeElement.IsOfKind(CodeMethodKind.Setter) && | ||
!(codeElement.IsOfKind(CodeMethodKind.Constructor) && parentClass.IsOfKind(CodeClassKind.RequestBuilder))) | ||
foreach (var parameter in codeElement.Parameters.Where(static x => !x.Optional).OrderBy(static x => x.Name)) | ||
{ | ||
var parameterName = parameter.Name; | ||
writer.StartBlock($"if {parameterName} is None:"); | ||
|
@@ -112,7 +112,7 @@ | |
break; | ||
} | ||
} | ||
private void WriteRawUrlBuilderBody(CodeClass parentClass, CodeMethod codeElement, LanguageWriter writer) | ||
{ | ||
var rawUrlParameter = codeElement.Parameters.OfKind(CodeParameterKind.RawUrl) ?? throw new InvalidOperationException("RawUrlBuilder method should have a RawUrl parameter"); | ||
var requestAdapterProperty = parentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) ?? throw new InvalidOperationException("RawUrlBuilder method should have a RequestAdapter property"); | ||
|
@@ -135,7 +135,7 @@ | |
writer.WriteLine($"return {parentClass.Name}()"); | ||
} | ||
private const string ResultVarName = "result"; | ||
private void WriteFactoryMethodBodyForUnionModel(CodeMethod codeElement, CodeClass parentClass, CodeParameter parseNodeParameter, LanguageWriter writer) | ||
{ | ||
writer.WriteLine($"{ResultVarName} = {parentClass.Name}()"); | ||
var includeElse = false; | ||
|
@@ -164,7 +164,7 @@ | |
} | ||
writer.WriteLine($"return {ResultVarName}"); | ||
} | ||
private void WriteFactoryMethodBodyForIntersectionModel(CodeMethod codeElement, CodeClass parentClass, CodeParameter parseNodeParameter, LanguageWriter writer) | ||
{ | ||
writer.WriteLine($"{ResultVarName} = {parentClass.Name}()"); | ||
var includeElse = false; | ||
|
@@ -324,7 +324,7 @@ | |
return _SetterAccessProperties; | ||
} | ||
} | ||
private void WriteConstructorBody(CodeClass parentClass, CodeMethod currentMethod, LanguageWriter writer, bool inherits) | ||
{ | ||
if (inherits && !parentClass.IsOfKind(CodeClassKind.Model)) | ||
{ | ||
|
@@ -373,7 +373,7 @@ | |
writer.IncreaseIndent(); | ||
} | ||
} | ||
private void WriteDirectAccessProperties(CodeClass parentClass, LanguageWriter writer) | ||
{ | ||
foreach (var propWithDefault in parentClass.GetPropertiesOfKind(DirectAccessProperties) | ||
.Where(static x => !string.IsNullOrEmpty(x.DefaultValue) && !NoneKeyword.Equals(x.DefaultValue, StringComparison.Ordinal)) | ||
|
@@ -390,7 +390,7 @@ | |
conventions.WriteInLineDescription(propWithDefault, writer); | ||
if (parentClass.IsOfKind(CodeClassKind.Model)) | ||
{ | ||
writer.WriteLine($"{propWithDefault.Name}: {(propWithDefault.Type.IsNullable ? "Optional[" : string.Empty)}{returnType}{(propWithDefault.Type.IsNullable ? "]" : string.Empty)} = {defaultValue}"); | ||
writer.WriteLine(); | ||
} | ||
else | ||
|
@@ -427,7 +427,7 @@ | |
} | ||
} | ||
private const string NoneKeyword = "None"; | ||
private void WriteSetterAccessPropertiesWithoutDefaults(CodeClass parentClass, LanguageWriter writer) | ||
{ | ||
foreach (var propWithoutDefault in parentClass.GetPropertiesOfKind(SetterAccessProperties) | ||
.Where(static x => string.IsNullOrEmpty(x.DefaultValue) || NoneKeyword.Equals(x.DefaultValue, StringComparison.Ordinal)) | ||
|
@@ -499,7 +499,7 @@ | |
else | ||
WriteDeserializerBodyForInheritedModel(inherits, codeElement, parentClass, writer); | ||
} | ||
private void WriteDeserializerBodyForUnionModel(CodeMethod method, CodeClass parentClass, LanguageWriter writer) | ||
{ | ||
foreach (var otherPropName in parentClass | ||
.GetPropertiesOfKind(CodePropertyKind.Custom) | ||
|
@@ -515,7 +515,7 @@ | |
} | ||
writer.WriteLine($"return {DefaultDeserializerValue}"); | ||
} | ||
private void WriteDeserializerBodyForIntersectionModel(CodeClass parentClass, LanguageWriter writer) | ||
{ | ||
var complexProperties = parentClass.GetPropertiesOfKind(CodePropertyKind.Custom) | ||
.Where(static x => x.Type is CodeType propType && propType.TypeDefinition is CodeClass && !x.Type.IsCollection) | ||
|
@@ -806,7 +806,8 @@ | |
private string GetTypeFactory(bool isVoid, bool isStream, string returnType) | ||
{ | ||
if (isVoid) return string.Empty; | ||
if (isStream || conventions.IsPrimitiveType(returnType)) return $" \"{returnType}\","; | ||
if (isStream || conventions.IsPrimitiveType(returnType)) return $" {returnType},"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we update/add a unit test for this so we prevent future regressions? |
||
|
||
return $" {returnType},"; | ||
} | ||
private string GetSendRequestMethodName(bool isVoid, bool isStream, bool isCollection, string returnType) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be moved to the unreleased section