Skip to content

Commit

Permalink
Merge pull request #3544 from microsoft/bugfix/csharp-override
Browse files Browse the repository at this point in the history
- fixes serialization/deserialization for inheritance in dotnet
  • Loading branch information
baywet authored Oct 23, 2023
2 parents 74a3f18 + a1ae19e commit 2557116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Fixed missing imports for method parameters that are query parameters.
- Replaces the use of "new" by "override" and "virtual" in CSharp models.
- Fixed query parameters type mapping for arrays. [#3354](https://github.com/microsoft/kiota/issues/3354)
- Fixed bug where base64url and decimal types would not be generated properly in Java.
- Fixed bug where symbol name cleanup would not work on forward single quotes characters [#3426](https://github.com/microsoft/kiota/issues/3426).
Expand Down
8 changes: 7 additions & 1 deletion src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,13 @@ private static string GetBaseSuffix(bool isConstructor, bool inherits, CodeClass
private void WriteMethodPrototype(CodeMethod code, CodeClass parentClass, LanguageWriter writer, string returnType, bool inherits, bool isVoid)
{
var staticModifier = code.IsStatic ? "static " : string.Empty;
var hideModifier = inherits && code.IsOfKind(CodeMethodKind.Serializer, CodeMethodKind.Deserializer, CodeMethodKind.Factory) ? "new " : string.Empty;
var hideModifier = (inherits, code.Kind) switch
{
(true, CodeMethodKind.Serializer or CodeMethodKind.Deserializer) => "override ",
(false, CodeMethodKind.Serializer or CodeMethodKind.Deserializer) => "virtual ",
(true, CodeMethodKind.Factory) => "new ",
_ => string.Empty
};
var genericTypePrefix = isVoid ? string.Empty : "<";
var genericTypeSuffix = code.IsAsync && !isVoid ? ">" : string.Empty;
var isConstructor = code.IsOfKind(CodeMethodKind.Constructor, CodeMethodKind.ClientConstructor, CodeMethodKind.RawUrlConstructor);
Expand Down

0 comments on commit 2557116

Please sign in to comment.