Skip to content

Can't use [JsonSerializable] with [Cloneable] source gen #65361

@DevronB

Description

@DevronB

Description

I'm using another source generator for marking classes as Cloneable. But when I annotate my class with this I get the following (unhelpful) errors for my JsonSerializerContext class.

using System.Text.Json.Serialization;
using Cloneable;

[JsonSerializable(typeof(jTest))]
internal partial class MyJsonContext : JsonSerializerContext
{
}

[Cloneable]
public partial class jTest
{
    [JsonPropertyName("xxx")]
    public string pTest { get; set; } = "blah";

    [JsonIgnore]
    public static string StoreExt => ".act.json";

    public bool IsNotStarted => false;
}
class MyJsonContext
'MyJsonContext' does not implement inherited abstract member 'JsonSerializerContext.GeneratedSerializerOptions.get' [GTCore]csharp(CS0534)
'MyJsonContext' does not implement inherited abstract member 'JsonSerializerContext.GetTypeInfo(Type)' [GTCore]csharp(CS0534)
There is no argument given that corresponds to the required formal parameter 'options' of 'JsonSerializerContext.JsonSerializerContext(JsonSerializerOptions?)' [GTCore]csharp(CS7036)

Are these generators conflicting somehow, is there a way around this so I can use both?

I'm wanting to use this on Wear OS net6.0-android as default serialization/deserialization is very slow. I guess if I could get some speed using JsonSerializerContext I could use it for cloning, but the issue still exists.

Any advice appreciated.

Reproduction Steps

As above

Expected behavior

don't know, merging of source gen results?

Actual behavior

as above

Regression?

No response

Known Workarounds

none

Configuration

tests above on net6.0 console app.

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions