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

System.Text.Json emits uncompilable code #103565

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

SteveDunn
Copy link
Contributor

Fix for #103515

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 17, 2024
Copy link
Contributor

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

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should

writer.WriteLine($"if ({propValueExpr} != null)");
change to is not as well?

@eiriktsarpalis
Copy link
Member

Thanks. Would it be possible to a couple of regression tests for the change as well? The relevant test suite can be found here:

[Fact]
public static void NoErrorsWhenUsingIgnoredReservedCSharpKeywords()
{
string source = """
using System.Text.Json.Serialization;
namespace Test
{
[JsonSerializable(typeof(ClassWithPropertyNameThatIsAReservedKeyword))]
public partial class JsonContext : JsonSerializerContext { }
public class ClassWithPropertyNameThatIsAReservedKeyword
{
[JsonIgnore]
public string @event { get; set; }
}
}
""";
Compilation compilation = CompilationHelper.CreateCompilation(source);
CompilationHelper.RunJsonSourceGenerator(compilation);
}

Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants