diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e61457df..98b81584ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs index 39724792ba..4cff2235f1 100644 --- a/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/CSharp/CodeMethodWriter.cs @@ -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);