Skip to content

Commit

Permalink
fix: do not emit ObsoleteAttribute on method parameters (#5228)
Browse files Browse the repository at this point in the history
* Add DoesNotWriteDeprecatedBodyParameterRequestBuilder test

* Fix GetParameterSignature

* Update CHANGELOG.md
  • Loading branch information
trejjam authored Aug 26, 2024
1 parent 76436f5 commit 022e3e9
Show file tree
Hide file tree
Showing 3 changed files with 23 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
- Added Collection, HashMap, Map, Objects, InputStream, BigDecimal to the list of reserved names for Java generation. [#5135](https://github.com/microsoft/kiota/issues/5135)
- C# refiner now fixes data types for indexers. [#5201](https://github.com/microsoft/kiota/issues/5201)
- C# do not report CS0618 in the generated code. [#5229](https://github.com/microsoft/kiota/issues/5229)
- C# do not decorate method parameter(s) with ObsoleteAttribute. [#5228](https://github.com/microsoft/kiota/issues/5228)

## [1.17.0] - 2024-08-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ _ when nameof(String).Equals(parameterType, StringComparison.OrdinalIgnoreCase)
_ when parameter.Optional => " = default",
_ => string.Empty,
};
return $"{GetDeprecationInformation(parameter)}{parameterType} {parameter.Name.ToFirstCharacterLowerCase()}{defaultValue}";
return $"{parameterType} {parameter.Name.ToFirstCharacterLowerCase()}{defaultValue}";
}
private string GetDeprecationInformation(IDeprecableElement element)
{
Expand Down
21 changes: 21 additions & 0 deletions tests/Kiota.Builder.Tests/Writers/CSharp/CodeMethodWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,27 @@ public void WritesPathParameterRequestBuilder()
Assert.Contains("return new", result);
}
[Fact]
public void DoesNotWriteDeprecatedBodyParameterRequestBuilder()
{
setup();
method.Kind = CodeMethodKind.RequestBuilderWithParameters;
method.AddParameter(new CodeParameter
{
Name = "pathParam",
Kind = CodeParameterKind.RequestBody,
Type = new CodeType
{
Name = "string"
},
Deprecation = new DeprecationInformation("parameter")
});
method.Deprecation = new DeprecationInformation("method");
writer.Write(method);
var result = tw.ToString();
Assert.Contains("[Obsolete(\"method\")]", result);
Assert.DoesNotContain("[Obsolete(\"parameter\")]", result);
}
[Fact]
public void WritesConstructor()
{
setup();
Expand Down

0 comments on commit 022e3e9

Please sign in to comment.