You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add [JsonIgnore] attribute to JsonPatch property for System.Text.Json compatibility (microsoft#8957)
- [x] Understand the issue and locate the relevant code
- [x] Add System.Text.Json.Serialization using statement to
ScmModelProvider.cs
- [x] Add [JsonIgnore] attribute to the JsonPatch property generation in
BuildJsonPatchProperty method
- [x] Update the test expectation files to include the new attribute
- [x] Build the project to verify changes
- [x] Run tests to validate the changes
- [x] Regenerate all generated libraries to ensure consistency
- [x] Add assertions to tests to verify JsonIgnore attribute is present
- [x] Add using alias to avoid fully qualified type name
- [x] Replace all instances with alias throughout test file
## Summary
Replaced all 13 instances of `ClientModel.Providers.ScmModelProvider` in
the test file with the `ScmModel` alias for consistency and improved
readability. This addresses the feedback to use the alias throughout the
entire file instead of just in the new method.
## Changes
- Replaced all occurrences of `ClientModel.Providers.ScmModelProvider`
with `ScmModel` in:
- Variable declarations (as cast operations)
- LINQ queries (OfType<> generic type arguments)
- Method parameters
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Add [JsonIgnore] to JsonPatch property to avoid
limitation in System.Text.Json</issue_title>
> <issue_description>### Clear and concise description of the problem
>
> Related to openai/openai-dotnet#817
>
> Right now System.Text.Json will error if they come across a ref struct
which JsonPatch properties are defined as. If we add this attribute it
will make STJ happy and MRW already ignores this so it should have no
impact there.
>
> ### Checklist
>
> - [x] Follow our [Code of
Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
> - [x] Read the [docs](https://typespec.io/docs/).
> - [x] Check that there isn't already an issue that request the same
feature to avoid creating a duplicate.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
- Fixesmicrosoft#8956
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ScmModelProvider.cs
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/ScmModelProviderTests.cs
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestCustomStructDynamicModel.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
usingSystem.ClientModel.Primitives;
6
6
usingSystem.ComponentModel;
7
7
usingSystem.Diagnostics.CodeAnalysis;
8
+
usingSystem.Text.Json.Serialization;
8
9
9
10
namespaceSample.Models
10
11
{
@@ -26,6 +27,7 @@ internal Cat(bool meows, in global::System.ClientModel.Primitives.JsonPatch patc
26
27
}
27
28
#pragma warning restore SCME0001// Type is for evaluation purposes only and is subject to change or removal in future updates.
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestDiscriminatedDynamicBaseModel.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
usingSystem.ClientModel.Primitives;
6
6
usingSystem.ComponentModel;
7
7
usingSystem.Diagnostics.CodeAnalysis;
8
+
usingSystem.Text.Json.Serialization;
8
9
9
10
namespaceSample.Models
10
11
{
@@ -26,6 +27,7 @@ internal Pet(string kind, in global::System.ClientModel.Primitives.JsonPatch pat
26
27
}
27
28
#pragma warning restore SCME0001// Type is for evaluation purposes only and is subject to change or removal in future updates.
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestDynamicModelWithPropagators.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
usingSystem.ClientModel.Primitives;
6
6
usingSystem.ComponentModel;
7
7
usingSystem.Diagnostics.CodeAnalysis;
8
+
usingSystem.Text.Json.Serialization;
8
9
9
10
namespaceSample.Models
10
11
{
@@ -26,6 +27,7 @@ internal DynamicModel(global::Sample.Models.AnotherDynamic p1, in global::System
26
27
}
27
28
#pragma warning restore SCME0001// Type is for evaluation purposes only and is subject to change or removal in future updates.
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestDynamicModelWithUnionAdditionalProps.cs
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestSimpleDynamicModel.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
usingSystem.ClientModel.Primitives;
6
6
usingSystem.ComponentModel;
7
7
usingSystem.Diagnostics.CodeAnalysis;
8
+
usingSystem.Text.Json.Serialization;
8
9
usingSample;
9
10
10
11
namespaceSample.Models
@@ -29,6 +30,7 @@ internal DynamicModel(string p1, in global::System.ClientModel.Primitives.JsonPa
29
30
}
30
31
#pragma warning restore SCME0001// Type is for evaluation purposes only and is subject to change or removal in future updates.
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestSingleDiscriminatorDynamicModel(True).cs
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ScmModelProvider/TestData/ScmModelProviderTests/TestStructDynamicModel.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
usingSystem.ClientModel.Primitives;
6
6
usingSystem.ComponentModel;
7
7
usingSystem.Diagnostics.CodeAnalysis;
8
+
usingSystem.Text.Json.Serialization;
8
9
9
10
namespaceSample.Models
10
11
{
@@ -26,6 +27,7 @@ internal Cat(bool meows, in global::System.ClientModel.Primitives.JsonPatch patc
26
27
}
27
28
#pragma warning restore SCME0001// Type is for evaluation purposes only and is subject to change or removal in future updates.
Copy file name to clipboardExpand all lines: packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/AnotherDynamicModel.cs
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
usingSystem.ClientModel.Primitives;
10
10
usingSystem.ComponentModel;
11
11
usingSystem.Diagnostics.CodeAnalysis;
12
+
usingSystem.Text.Json.Serialization;
12
13
13
14
namespaceSampleTypeSpec
14
15
{
@@ -40,6 +41,7 @@ internal AnotherDynamicModel(string bar, in JsonPatch patch)
40
41
#pragma warning restore SCME0001// Type is for evaluation purposes only and is subject to change or removal in future updates.
0 commit comments