Description
For this sample:
public class Outer
{
internal class Inner
{
public string? Name { get; init; }
}
[JsonSerializable(typeof(Inner))]
internal partial class InnerJsonContext : JsonSerializerContext
{ }
}
[JsonSerializable(typeof(Outer.Inner))]
public partial class OuterInnerJsonContext : JsonSerializerContext
{ }
The OuterInnerJsonContext is ok, but InnerJsonContext has 3 compiler errors:
- CS0534: 'Outer.InnerJsonContext' does not implement inherited abstract member 'JsonSerializerContext.GeneratedSerializerOptions.get'
- CS0534: 'Outer.InnerJsonContext' does not implement inherited abstract member 'JsonSerializerContext.GetTypeInfo(Type)'
- CS7036: There is no argument given that corresponds to the required formal parameter 'options' of 'JsonSerializerContext.JsonSerializerContext(JsonSerializerOptions?)'
But my requirement is make the Inner class private, because it should be hidden. So the OuterInnerJsonContext is not applicable.
I have a repro in Outer.cs showing this issue. Uncomment to see the compiler errors.
Reproduction Steps
- Clone repro, open with Visual Studio.
- Open Net60Tests\Outer.cs
- Build without error, tests pass.
- Uncomment all, then 3 errors appear on
InnerJsonContext.
Expected behavior
It compiles without errors, and tests pass.
Actual behavior
InnerJsonContext has 3 compiler errors:
- CS0534: 'Outer.InnerJsonContext' does not implement inherited abstract member 'JsonSerializerContext.GeneratedSerializerOptions.get'
- CS0534: 'Outer.InnerJsonContext' does not implement inherited abstract member 'JsonSerializerContext.GetTypeInfo(Type)'
- CS7036: There is no argument given that corresponds to the required formal parameter 'options' of 'JsonSerializerContext.JsonSerializerContext(JsonSerializerOptions?)'
Regression?
Don't know.
Known Workarounds
Make Inner class internal instead of private, then add OuterInnerJsonContext class outside of Outer class.
Configuration
.NET 6.0, Visual Studio 2022 17.1.0 Preview 1.0.
Other information
Don't know.
Description
For this sample:
The
OuterInnerJsonContextis ok, butInnerJsonContexthas 3 compiler errors:But my requirement is make the
Innerclassprivate, because it should be hidden. So theOuterInnerJsonContextis not applicable.I have a repro in Outer.cs showing this issue. Uncomment to see the compiler errors.
Reproduction Steps
InnerJsonContext.Expected behavior
It compiles without errors, and tests pass.
Actual behavior
InnerJsonContexthas 3 compiler errors:Regression?
Don't know.
Known Workarounds
Make
Innerclassinternalinstead ofprivate, then addOuterInnerJsonContextclass outside ofOuterclass.Configuration
.NET 6.0, Visual Studio 2022 17.1.0 Preview 1.0.
Other information
Don't know.