-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 does not correctly handle nested inner types of a generic outer type. #62762
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsDescriptionI'm seeing an Reproduction StepsAttempt to compile the following code: using System.Text.Json.Serialization;
public class Outer<T>
{
public class Inner { }
}
public class C
{
public Outer<int>.Inner I { get; set; }
}
[JsonSerializable(typeof(C))]
public partial class Context : JsonSerializerContext
{
public static string Implicit => "World";
} Expected behaviorThe code compiles. Actual behaviorCSC : 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 'ArgumentOutOfRangeException' with message 'Length cannot be less than zero. (Parameter 'length')' [C:\Users\333fr\Documents\git\omnisharp-roslyn\src\OmniSharp.Abstractions\OmniSharp.Abstractions.csproj] Followed by errors from lack of partial type implementation. Regression?No response Known WorkaroundsNo response Configuration.NET 6.0.100. Other informationNo response
|
This is a bug with correctly generating the full name of some generic types. The full name is used as part of generator's infrastructure for processing serializable types. This bug should be fixed and considered for 6.0 since we have no control of input object graphs and it would be difficult to communicate what's working vs not. |
The fix for this issue should verify correctness for these scenarios:
We'll target 7.0 for a fix here. A community contribution/fix here is welcome. |
Moving to .NET 8 milestone. |
This is fixed with #71619 |
Description
I'm seeing an
ArgumentOutOfRange
exception when attempting to use the System.Text.Json source generator in my project. This appears to be when a field or property of a type to be generated is of the formOuterType<T>.Inner
.Reproduction Steps
Attempt to compile the following code:
Expected behavior
The code compiles.
Actual behavior
Followed by errors from lack of partial type implementation.
Regression?
No response
Known Workarounds
No response
Configuration
.NET 6.0.100.
Other information
No response
The text was updated successfully, but these errors were encountered: