Skip to content

Commit

Permalink
Merge branch 'main' into nikithauc/test-index
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet authored Mar 21, 2022
2 parents f3804be + ff9526e commit 7998bec
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- TypeScript adding index exporting models to fix #870.
- Fixed a bug where JSON serialization would fail on nil properties in Go.

## [0.0.19] - 2022-03-18

Expand Down
2 changes: 0 additions & 2 deletions abstractions/go/serialization/parsable.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ type Parsable interface {
Serialize(writer SerializationWriter) error
// GetFieldDeserializers returns the deserialization information for this object.
GetFieldDeserializers() map[string]func(interface{}, ParseNode) error
// IsNil returns whether the current object is nil or not.
IsNil() bool
}

// ParsableFactory is a factory for creating Parsable.
Expand Down
2 changes: 1 addition & 1 deletion serialization/go/json/json_serialization_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (w *JsonSerializationWriter) WriteByteArrayValue(key string, value []byte)

// WriteObjectValue writes a Parsable value to underlying the byte array.
func (w *JsonSerializationWriter) WriteObjectValue(key string, item absser.Parsable) error {
if !item.IsNil() {
if item != nil {
if key != "" {
w.writePropertyName(key)
}
Expand Down
1 change: 0 additions & 1 deletion src/Kiota.Builder/CodeDOM/CodeMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public enum CodeMethodKind
RequestBuilderBackwardCompatibility,
RequestBuilderWithParameters,
RawUrlConstructor,
NullCheck,
CommandBuilder,
/// <summary>
/// The method to be used during deserialization with the discriminator property to get a new instance of the target type.
Expand Down
18 changes: 0 additions & 18 deletions src/Kiota.Builder/Refiners/GoRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public override void Refine(CodeNamespace generatedCode)
generatedCode,
_configuration.UsesBackingStore
);
AddNullCheckMethods(
generatedCode
);
AddRawUrlConstructorOverload(
generatedCode
);
Expand Down Expand Up @@ -170,21 +167,6 @@ private static void ReplaceExecutorAndGeneratorParametersByParameterSets(CodeEle
}
CrawlTree(currentElement, ReplaceExecutorAndGeneratorParametersByParameterSets);
}
private static void AddNullCheckMethods(CodeElement currentElement) {
if(currentElement is CodeClass currentClass && currentClass.IsOfKind(CodeClassKind.Model)) {
currentClass.AddMethod(new CodeMethod {
Name = "IsNil",
IsAsync = false,
Kind = CodeMethodKind.NullCheck,
ReturnType = new CodeType {
Name = "boolean",
IsExternal = true,
IsNullable = false,
},
});
}
CrawlTree(currentElement, AddNullCheckMethods);
}
private static void RemoveModelPropertiesThatDependOnSubNamespaces(CodeElement currentElement) {
if(currentElement is CodeClass currentClass &&
currentClass.IsOfKind(CodeClassKind.Model) &&
Expand Down
2 changes: 0 additions & 2 deletions src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ protected virtual void HandleMethodKind(CodeMethod codeElement, LanguageWriter w
throw new InvalidOperationException("getters and setters are automatically added on fields in dotnet");
case CodeMethodKind.RequestBuilderBackwardCompatibility:
throw new InvalidOperationException("RequestBuilderBackwardCompatibility is not supported as the request builders are implemented by properties.");
case CodeMethodKind.NullCheck:
throw new InvalidOperationException("NullChecks are not required in C#");
case CodeMethodKind.CommandBuilder:
var origParams = codeElement.OriginalMethod?.Parameters ?? codeElement.Parameters;
requestBodyParam = origParams.OfKind(CodeParameterKind.RequestBody);
Expand Down
10 changes: 1 addition & 9 deletions src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri
case CodeMethodKind.RequestBuilderWithParameters:
WriteRequestBuilderBody(parentClass, codeElement, writer);
break;
case CodeMethodKind.NullCheck:
WriteNullCheckBody(writer);
break;
case CodeMethodKind.Factory:
WriteFactoryMethodBody(codeElement, writer);
break;
Expand Down Expand Up @@ -116,10 +113,6 @@ private void WriteMethodDocumentation(CodeMethod code, string methodName, Langua
if(!string.IsNullOrEmpty(code.Description))
conventions.WriteShortDescription($"{methodName.ToFirstCharacterUpperCase()} {code.Description.ToFirstCharacterLowerCase()}", writer);
}
private static void WriteNullCheckBody(LanguageWriter writer)
{
writer.WriteLine("return m == nil");
}
private const string TempParamsVarName = "urlParams";
private static void WriteRawUrlConstructorBody(CodeClass parentClass, CodeMethod codeElement, LanguageWriter writer)
{
Expand Down Expand Up @@ -185,8 +178,7 @@ private void WriteMethodPrototype(CodeMethod code, LanguageWriter writer, string
CodeMethodKind.Deserializer,
CodeMethodKind.RequestBuilderWithParameters,
CodeMethodKind.RequestBuilderBackwardCompatibility,
CodeMethodKind.RawUrlConstructor,
CodeMethodKind.NullCheck) || code.IsAsync ?
CodeMethodKind.RawUrlConstructor) || code.IsAsync ?
string.Empty :
"error";
if(!string.IsNullOrEmpty(finalReturnType) && !string.IsNullOrEmpty(errorDeclaration))
Expand Down
2 changes: 0 additions & 2 deletions src/Kiota.Builder/Writers/Java/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri
break;
case CodeMethodKind.RequestBuilderBackwardCompatibility:
throw new InvalidOperationException("RequestBuilderBackwardCompatibility is not supported as the request builders are implemented by properties.");
case CodeMethodKind.NullCheck:
throw new InvalidOperationException("NullChecks are not required in Java");
case CodeMethodKind.Factory:
WriteFactoryMethodBody(codeElement, writer);
break;
Expand Down

0 comments on commit 7998bec

Please sign in to comment.