Skip to content

STJ Source Generator bloats the assembly when used with records #58136

@aromaa

Description

@aromaa

Description

Records contains a property EqualityContract of type Type. This leads to the generator generating serializers for many of the reflection related types as for example Type, ConstructorInfo, MethodInfo, Assembly, Module, etc.

Also it would be nice if there was a way to prevent generating metadata for non-public members.

Repo

internal static class Program
{
	private static void Main()
	{
		JsonSerializer.Serialize(new Test(), typeof(Test), JsonContext.Default);
	}
}

internal sealed record Test;

[JsonSerializable(typeof(Test))]
internal sealed partial class JsonContext : JsonSerializerContext
{
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions