Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #77019
DevronB opened this issue Feb 15, 2022 · 5 comments
Closed
Tracked by #77019

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

DevronB opened this issue Feb 15, 2022 · 5 comments
Labels
area-System.Text.Json bug help wanted [up-for-grabs] Good issue for external contributors source-generator Indicates an issue with a source generator feature
Milestone

Comments

@DevronB
Copy link

DevronB commented Feb 15, 2022

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

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Feb 15, 2022
@ghost
Copy link

ghost commented Feb 15, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: DevronB
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@layomia
Copy link
Contributor

layomia commented Mar 7, 2022

Might be a dup of #62937.

@layomia layomia removed the untriaged New issue has not been triaged by the area owner label Mar 7, 2022
@layomia layomia self-assigned this Mar 7, 2022
@layomia layomia added this to the 7.0.0 milestone Mar 7, 2022
@eiriktsarpalis eiriktsarpalis modified the milestones: 7.0.0, 8.0.0 Jul 19, 2022
@eiriktsarpalis
Copy link
Member

Moving to the .NET 8 milestone.

@krwq krwq added the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Sep 28, 2022
@eiriktsarpalis
Copy link
Member

Source generator throwing the following error:

CSC : warning CS8785: Generator 'JsonSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidOperationException' with message 'Operation is not valid due to the current state of the object.'

Need to debug the source generator to root cause the underlying issue.

@eiriktsarpalis eiriktsarpalis added the source-generator Indicates an issue with a source generator feature label Jan 23, 2023
@eiriktsarpalis eiriktsarpalis removed this from the 8.0.0 milestone Jan 23, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 23, 2023
@eiriktsarpalis eiriktsarpalis added bug help wanted [up-for-grabs] Good issue for external contributors and removed untriaged New issue has not been triaged by the area owner needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration labels Jan 23, 2023
@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jan 23, 2023
@eiriktsarpalis eiriktsarpalis modified the milestones: 8.0.0, Future May 31, 2023
@eiriktsarpalis eiriktsarpalis modified the milestones: Future, 8.0.0 Jun 7, 2023
@eiriktsarpalis
Copy link
Member

Can confirm this has been fixed by #87383

@ghost ghost locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json bug help wanted [up-for-grabs] Good issue for external contributors source-generator Indicates an issue with a source generator feature
Projects
None yet
Development

No branches or pull requests

4 participants