diff --git a/src/libraries/System.Text.Json/Common/JsonConstants.cs b/src/libraries/System.Text.Json/Common/JsonConstants.cs index 0d121d9c6ffbc..63bf065d12687 100644 --- a/src/libraries/System.Text.Json/Common/JsonConstants.cs +++ b/src/libraries/System.Text.Json/Common/JsonConstants.cs @@ -5,9 +5,6 @@ namespace System.Text.Json { internal static partial class JsonConstants { - // The maximum number of parameters a constructor can have where it can be supported by the serializer. - public const int MaxParameterCount = 64; - // Standard format for double and single on non-inbox frameworks. public const string DoubleFormatString = "G17"; public const string SingleFormatString = "G9"; diff --git a/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs b/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs index 68b0bf76bf975..db7b990e095d9 100644 --- a/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs +++ b/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs @@ -951,11 +951,6 @@ private static string GetParameterizedCtorInvocationFunc(TypeGenerationSpec type int paramCount = parameters.Length; Debug.Assert(paramCount != 0); - if (paramCount > JsonConstants.MaxParameterCount) - { - return "null"; - } - const string ArgsVarName = "args"; int lastIndex = paramCount - 1; diff --git a/src/libraries/System.Text.Json/src/Resources/Strings.resx b/src/libraries/System.Text.Json/src/Resources/Strings.resx index 2f466b9c05d44..ecd19e18c447d 100644 --- a/src/libraries/System.Text.Json/src/Resources/Strings.resx +++ b/src/libraries/System.Text.Json/src/Resources/Strings.resx @@ -485,9 +485,6 @@ Each parameter in the deserialization constructor on type '{0}' must bind to an object property or field on deserialization. Each parameter name must match with a property or field on the object. Fields are only considered when 'JsonSerializerOptions.IncludeFields' is enabled. The match can be case-insensitive. - - The deserialization constructor on type '{0}' may not have more than 64 parameters for deserialization. - Reference metadata is not supported when deserializing constructor parameters. See type '{0}'. diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Object/ObjectWithParameterizedConstructorConverter.Large.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Object/ObjectWithParameterizedConstructorConverter.Large.cs index 938d2a9605699..f87356505ad78 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Object/ObjectWithParameterizedConstructorConverter.Large.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Object/ObjectWithParameterizedConstructorConverter.Large.cs @@ -34,16 +34,13 @@ protected sealed override bool ReadAndCacheConstructorArgument(scoped ref ReadSt protected sealed override object CreateObject(ref ReadStackFrame frame) { - object[] arguments = (object[])frame.CtorArgumentState!.Arguments; - frame.CtorArgumentState.Arguments = null!; + Debug.Assert(frame.CtorArgumentState != null); + Debug.Assert(frame.JsonTypeInfo.CreateObjectWithArgs != null); - var createObject = (Func?)frame.JsonTypeInfo.CreateObjectWithArgs; + object[] arguments = (object[])frame.CtorArgumentState.Arguments; + frame.CtorArgumentState.Arguments = null!; - if (createObject == null) - { - // This means this constructor has more than 64 parameters. - ThrowHelper.ThrowNotSupportedException_ConstructorMaxOf64Parameters(TypeToConvert); - } + Func createObject = (Func)frame.JsonTypeInfo.CreateObjectWithArgs; object obj = createObject(arguments); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/MemberAccessor.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/MemberAccessor.cs index d685d241628bf..326ab657b8899 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/MemberAccessor.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/MemberAccessor.cs @@ -12,7 +12,7 @@ internal abstract class MemberAccessor public abstract Func? CreateConstructor( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type classType); - public abstract Func? CreateParameterizedConstructor(ConstructorInfo constructor); + public abstract Func CreateParameterizedConstructor(ConstructorInfo constructor); public abstract JsonTypeInfo.ParameterizedConstructorDelegate? CreateParameterizedConstructor(ConstructorInfo constructor); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitCachingMemberAccessor.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitCachingMemberAccessor.cs index 3eccece6f15f0..a243f4be4d86a 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitCachingMemberAccessor.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitCachingMemberAccessor.cs @@ -45,7 +45,7 @@ public override Func, TCollection> CreateImmutableEnumerab => s_cache.GetOrAdd((nameof(CreateImmutableEnumerableCreateRangeDelegate), typeof((TCollection, TElement)), null), static (_) => s_sourceAccessor.CreateImmutableEnumerableCreateRangeDelegate()); - public override Func? CreateParameterizedConstructor(ConstructorInfo constructor) + public override Func CreateParameterizedConstructor(ConstructorInfo constructor) => s_cache.GetOrAdd((nameof(CreateParameterizedConstructor), typeof(T), constructor), static key => s_sourceAccessor.CreateParameterizedConstructor((ConstructorInfo)key.member!)); public override JsonTypeInfo.ParameterizedConstructorDelegate? CreateParameterizedConstructor(ConstructorInfo constructor) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitMemberAccessor.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitMemberAccessor.cs index bb5970821ce21..106c07b1e7a12 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitMemberAccessor.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitMemberAccessor.cs @@ -59,13 +59,13 @@ internal sealed class ReflectionEmitMemberAccessor : MemberAccessor generator.Emit(OpCodes.Ret); - return (Func)dynamicMethod.CreateDelegate(typeof(Func)); + return CreateDelegate>(dynamicMethod); } - public override Func? CreateParameterizedConstructor(ConstructorInfo constructor) => + public override Func CreateParameterizedConstructor(ConstructorInfo constructor) => CreateDelegate>(CreateParameterizedConstructor(constructor)); - private static DynamicMethod? CreateParameterizedConstructor(ConstructorInfo constructor) + private static DynamicMethod CreateParameterizedConstructor(ConstructorInfo constructor) { Type? type = constructor.DeclaringType; @@ -76,11 +76,6 @@ internal sealed class ReflectionEmitMemberAccessor : MemberAccessor ParameterInfo[] parameters = constructor.GetParameters(); int parameterCount = parameters.Length; - if (parameterCount > JsonConstants.MaxParameterCount) - { - return null; - } - var dynamicMethod = new DynamicMethod( ConstructorInfo.ConstructorName, type, @@ -95,7 +90,7 @@ internal sealed class ReflectionEmitMemberAccessor : MemberAccessor Type paramType = parameters[i].ParameterType; generator.Emit(OpCodes.Ldarg_0); - generator.Emit(OpCodes.Ldc_I4_S, i); + generator.Emit(OpCodes.Ldc_I4, i); generator.Emit(OpCodes.Ldelem_Ref); generator.Emit(OpCodes.Unbox_Any, paramType); } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionMemberAccessor.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionMemberAccessor.cs index 9914033a11bed..606ad6aba79c2 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionMemberAccessor.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionMemberAccessor.cs @@ -41,7 +41,7 @@ public ConstructorContext([DynamicallyAccessedMembers(DynamicallyAccessedMemberT return new ConstructorContext(type).CreateInstance!; } - public override Func? CreateParameterizedConstructor(ConstructorInfo constructor) + public override Func CreateParameterizedConstructor(ConstructorInfo constructor) { Type type = typeof(T); @@ -50,11 +50,6 @@ public ConstructorContext([DynamicallyAccessedMembers(DynamicallyAccessedMemberT int parameterCount = constructor.GetParameters().Length; - if (parameterCount > JsonConstants.MaxParameterCount) - { - return null; - } - return (arguments) => { // The input array was rented from the shared ArrayPool, so its size is likely to be larger than the param count. diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs b/src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs index 23c0006fa37d7..84ab305039565 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.Serialization.cs @@ -40,12 +40,6 @@ public static void ThrowNotSupportedException_TypeRequiresAsyncSerialization(Typ throw new NotSupportedException(SR.Format(SR.TypeRequiresAsyncSerialization, propertyType)); } - [DoesNotReturn] - public static void ThrowNotSupportedException_ConstructorMaxOf64Parameters(Type type) - { - throw new NotSupportedException(SR.Format(SR.ConstructorMaxOf64Parameters, type)); - } - [DoesNotReturn] public static void ThrowNotSupportedException_DictionaryKeyTypeNotSupported(Type keyType, JsonConverter converter) { diff --git a/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.ParameterMatching.cs b/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.ParameterMatching.cs index 39becedff9923..b0561b22a6201 100644 --- a/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.ParameterMatching.cs +++ b/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.ParameterMatching.cs @@ -726,7 +726,7 @@ async Task RunTestAsync() } [Fact] - public async Task Cannot_Deserialize_ObjectWith_Ctor_With_65_Params() + public async Task Can_Deserialize_ObjectWith_Ctor_With_65_Params() { async Task RunTestAsync() { @@ -752,11 +752,8 @@ async Task RunTestAsync() sb.Append("Int32"); sb.Append(")"); - NotSupportedException ex = await Assert.ThrowsAsync(() => Serializer.DeserializeWrapper(input)); - Assert.Contains(type.ToString(), ex.ToString()); - - ex = await Assert.ThrowsAsync(() => Serializer.DeserializeWrapper("{}")); - Assert.Contains(type.ToString(), ex.ToString()); + T value = await Serializer.DeserializeWrapper(input); + value = await Serializer.DeserializeWrapper("{}"); } await RunTestAsync(); @@ -1426,6 +1423,17 @@ public async Task TestClassWithDefaultCtorParams() JsonTestHelper.AssertJsonEqual(json, await Serializer.SerializeWrapper(obj)); } + [Fact] + public async Task TestClassWithManyConstructorParameters() + { + ClassWithManyConstructorParameters value = ClassWithManyConstructorParameters.Create(); + string json = JsonSerializer.Serialize(value); + + ClassWithManyConstructorParameters result = await Serializer.DeserializeWrapper(json); + + Assert.Equal(value, result); // Type is C# record that implements structural equality. + } + public class ClassWithDefaultCtorParams { public Point_2D_Struct_WithAttribute Struct { get; } diff --git a/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.Stream.cs b/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.Stream.cs index 5c96e06c1f23b..28dda8e5b3097 100644 --- a/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.Stream.cs +++ b/src/libraries/System.Text.Json/tests/Common/ConstructorTests/ConstructorTests.Stream.cs @@ -118,7 +118,7 @@ async Task RunTestAsync(string testData) } [Fact] - public async Task Cannot_DeserializeAsync_ObjectWith_Ctor_With_65_Params() + public async Task Can_DeserializeAsync_ObjectWith_Ctor_With_65_Params() { if (StreamingSerializer is null) { @@ -137,6 +137,7 @@ async Task RunTestAsync() sb.Append("}"); string input = sb.ToString(); + T value; using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(input))) { @@ -145,7 +146,7 @@ async Task RunTestAsync() DefaultBufferSize = 1 }; - await Assert.ThrowsAsync(async () => await StreamingSerializer.DeserializeWrapper(stream, options)); + value = await StreamingSerializer.DeserializeWrapper(stream, options); } using (MemoryStream stream = new MemoryStream("{}"u8.ToArray())) @@ -155,7 +156,7 @@ async Task RunTestAsync() DefaultBufferSize = 1 }; - await Assert.ThrowsAsync(async () => await StreamingSerializer.DeserializeWrapper(stream, options)); + value = await StreamingSerializer.DeserializeWrapper(stream, options); } } diff --git a/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.Constructor.cs b/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.Constructor.cs index 35e065a11d3b0..28e9e2dbbd409 100644 --- a/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.Constructor.cs +++ b/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.Constructor.cs @@ -2389,4 +2389,212 @@ public struct StructWithFourArgs [JsonConstructor] public StructWithFourArgs(int w, int x, int y, int z) => (W, X, Y, Z) = (w, x, y, z); } + + public record ClassWithManyConstructorParameters( + int P000, int P001, int P002, int P003, int P004, int P005, int P006, int P007, int P008, int P009, + int P010, int P011, int P012, int P013, int P014, int P015, int P016, int P017, int P018, int P019, + int P020, int P021, int P022, int P023, int P024, int P025, int P026, int P027, int P028, int P029, + int P030, int P031, int P032, int P033, int P034, int P035, int P036, int P037, int P038, int P039, + int P040, int P041, int P042, int P043, int P044, int P045, int P046, int P047, int P048, int P049, + int P050, int P051, int P052, int P053, int P054, int P055, int P056, int P057, int P058, int P059, + int P060, int P061, int P062, int P063, int P064, int P065, int P066, int P067, int P068, int P069, + int P070, int P071, int P072, int P073, int P074, int P075, int P076, int P077, int P078, int P079, + int P080, int P081, int P082, int P083, int P084, int P085, int P086, int P087, int P088, int P089, + int P090, int P091, int P092, int P093, int P094, int P095, int P096, int P097, int P098, int P099, + int P100, int P101, int P102, int P103, int P104, int P105, int P106, int P107, int P108, int P109, + int P110, int P111, int P112, int P113, int P114, int P115, int P116, int P117, int P118, int P119, + int P120, int P121, int P122, int P123, int P124, int P125, int P126, int P127, int P128, int P129, + int P130, int P131, int P132, int P133, int P134, int P135, int P136, int P137, int P138, int P139, + int P140, int P141, int P142, int P143, int P144, int P145, int P146, int P147, int P148, int P149, + int P150, int P151, int P152, int P153, int P154, int P155, int P156, int P157, int P158, int P159, + int P160, int P161, int P162, int P163, int P164, int P165, int P166, int P167, int P168, int P169, + int P170, int P171, int P172, int P173, int P174, int P175, int P176, int P177, int P178, int P179, + int P180, int P181, int P182, int P183, int P184, int P185, int P186, int P187, int P188, int P189, + int P190, int P191, int P192, int P193, int P194, int P195, int P196, int P197, int P198, int P199, + int P200, int P201, int P202, int P203, int P204, int P205, int P206, int P207, int P208, int P209, + int P210, int P211, int P212, int P213, int P214, int P215, int P216, int P217, int P218, int P219, + int P220, int P221, int P222, int P223, int P224, int P225, int P226, int P227, int P228, int P229, + int P230, int P231, int P232, int P233, int P234, int P235, int P236, int P237, int P238, int P239, + int P240, int P241, int P242, int P243, int P244, int P245, int P246, int P247, int P248, int P249, + int P250, int P251, int P252, int P253, int P254, int P255, int P256, int P257, int P258, int P259, + int P260, int P261, int P262, int P263, int P264, int P265, int P266, int P267, int P268, int P269, + int P270, int P271, int P272, int P273, int P274, int P275, int P276, int P277, int P278, int P279, + int P280, int P281, int P282, int P283, int P284, int P285, int P286, int P287, int P288, int P289, + int P290, int P291, int P292, int P293, int P294, int P295, int P296, int P297, int P298, int P299, + int P300, int P301, int P302, int P303, int P304, int P305, int P306, int P307, int P308, int P309, + int P310, int P311, int P312, int P313, int P314, int P315, int P316, int P317, int P318, int P319, + int P320, int P321, int P322, int P323, int P324, int P325, int P326, int P327, int P328, int P329, + int P330, int P331, int P332, int P333, int P334, int P335, int P336, int P337, int P338, int P339, + int P340, int P341, int P342, int P343, int P344, int P345, int P346, int P347, int P348, int P349, + int P350, int P351, int P352, int P353, int P354, int P355, int P356, int P357, int P358, int P359, + int P360, int P361, int P362, int P363, int P364, int P365, int P366, int P367, int P368, int P369, + int P370, int P371, int P372, int P373, int P374, int P375, int P376, int P377, int P378, int P379, + int P380, int P381, int P382, int P383, int P384, int P385, int P386, int P387, int P388, int P389, + int P390, int P391, int P392, int P393, int P394, int P395, int P396, int P397, int P398, int P399, + int P400, int P401, int P402, int P403, int P404, int P405, int P406, int P407, int P408, int P409, + int P410, int P411, int P412, int P413, int P414, int P415, int P416, int P417, int P418, int P419, + int P420, int P421, int P422, int P423, int P424, int P425, int P426, int P427, int P428, int P429, + int P430, int P431, int P432, int P433, int P434, int P435, int P436, int P437, int P438, int P439, + int P440, int P441, int P442, int P443, int P444, int P445, int P446, int P447, int P448, int P449, + int P450, int P451, int P452, int P453, int P454, int P455, int P456, int P457, int P458, int P459, + int P460, int P461, int P462, int P463, int P464, int P465, int P466, int P467, int P468, int P469, + int P470, int P471, int P472, int P473, int P474, int P475, int P476, int P477, int P478, int P479, + int P480, int P481, int P482, int P483, int P484, int P485, int P486, int P487, int P488, int P489, + int P490, int P491, int P492, int P493, int P494, int P495, int P496, int P497, int P498, int P499, + int P500, int P501, int P502, int P503, int P504, int P505, int P506, int P507, int P508, int P509, + int P510, int P511, int P512, int P513, int P514, int P515, int P516, int P517, int P518, int P519, + int P520, int P521, int P522, int P523, int P524, int P525, int P526, int P527, int P528, int P529, + int P530, int P531, int P532, int P533, int P534, int P535, int P536, int P537, int P538, int P539, + int P540, int P541, int P542, int P543, int P544, int P545, int P546, int P547, int P548, int P549, + int P550, int P551, int P552, int P553, int P554, int P555, int P556, int P557, int P558, int P559, + int P560, int P561, int P562, int P563, int P564, int P565, int P566, int P567, int P568, int P569, + int P570, int P571, int P572, int P573, int P574, int P575, int P576, int P577, int P578, int P579, + int P580, int P581, int P582, int P583, int P584, int P585, int P586, int P587, int P588, int P589, + int P590, int P591, int P592, int P593, int P594, int P595, int P596, int P597, int P598, int P599, + int P600, int P601, int P602, int P603, int P604, int P605, int P606, int P607, int P608, int P609, + int P610, int P611, int P612, int P613, int P614, int P615, int P616, int P617, int P618, int P619, + int P620, int P621, int P622, int P623, int P624, int P625, int P626, int P627, int P628, int P629, + int P630, int P631, int P632, int P633, int P634, int P635, int P636, int P637, int P638, int P639, + int P640, int P641, int P642, int P643, int P644, int P645, int P646, int P647, int P648, int P649, + int P650, int P651, int P652, int P653, int P654, int P655, int P656, int P657, int P658, int P659, + int P660, int P661, int P662, int P663, int P664, int P665, int P666, int P667, int P668, int P669, + int P670, int P671, int P672, int P673, int P674, int P675, int P676, int P677, int P678, int P679, + int P680, int P681, int P682, int P683, int P684, int P685, int P686, int P687, int P688, int P689, + int P690, int P691, int P692, int P693, int P694, int P695, int P696, int P697, int P698, int P699, + int P700, int P701, int P702, int P703, int P704, int P705, int P706, int P707, int P708, int P709, + int P710, int P711, int P712, int P713, int P714, int P715, int P716, int P717, int P718, int P719, + int P720, int P721, int P722, int P723, int P724, int P725, int P726, int P727, int P728, int P729, + int P730, int P731, int P732, int P733, int P734, int P735, int P736, int P737, int P738, int P739, + int P740, int P741, int P742, int P743, int P744, int P745, int P746, int P747, int P748, int P749, + int P750, int P751, int P752, int P753, int P754, int P755, int P756, int P757, int P758, int P759, + int P760, int P761, int P762, int P763, int P764, int P765, int P766, int P767, int P768, int P769, + int P770, int P771, int P772, int P773, int P774, int P775, int P776, int P777, int P778, int P779, + int P780, int P781, int P782, int P783, int P784, int P785, int P786, int P787, int P788, int P789, + int P790, int P791, int P792, int P793, int P794, int P795, int P796, int P797, int P798, int P799, + int P800, int P801, int P802, int P803, int P804, int P805, int P806, int P807, int P808, int P809, + int P810, int P811, int P812, int P813, int P814, int P815, int P816, int P817, int P818, int P819, + int P820, int P821, int P822, int P823, int P824, int P825, int P826, int P827, int P828, int P829, + int P830, int P831, int P832, int P833, int P834, int P835, int P836, int P837, int P838, int P839, + int P840, int P841, int P842, int P843, int P844, int P845, int P846, int P847, int P848, int P849, + int P850, int P851, int P852, int P853, int P854, int P855, int P856, int P857, int P858, int P859, + int P860, int P861, int P862, int P863, int P864, int P865, int P866, int P867, int P868, int P869, + int P870, int P871, int P872, int P873, int P874, int P875, int P876, int P877, int P878, int P879, + int P880, int P881, int P882, int P883, int P884, int P885, int P886, int P887, int P888, int P889, + int P890, int P891, int P892, int P893, int P894, int P895, int P896, int P897, int P898, int P899, + int P900, int P901, int P902, int P903, int P904, int P905, int P906, int P907, int P908, int P909, + int P910, int P911, int P912, int P913, int P914, int P915, int P916, int P917, int P918, int P919, + int P920, int P921, int P922, int P923, int P924, int P925, int P926, int P927, int P928, int P929, + int P930, int P931, int P932, int P933, int P934, int P935, int P936, int P937, int P938, int P939, + int P940, int P941, int P942, int P943, int P944, int P945, int P946, int P947, int P948, int P949, + int P950, int P951, int P952, int P953, int P954, int P955, int P956, int P957, int P958, int P959, + int P960, int P961, int P962, int P963, int P964, int P965, int P966, int P967, int P968, int P969, + int P970, int P971, int P972, int P973, int P974, int P975, int P976, int P977, int P978, int P979, + int P980, int P981, int P982, int P983, int P984, int P985, int P986, int P987, int P988, int P989, + int P990, int P991, int P992, int P993, int P994, int P995, int P996, int P997, int P998, int P999) + { + public static ClassWithManyConstructorParameters Create() + { + return new ClassWithManyConstructorParameters( + P000: 000, P001: 001, P002: 002, P003: 003, P004: 004, P005: 005, P006: 006, P007: 007, P008: 008, P009: 009, + P010: 010, P011: 011, P012: 012, P013: 013, P014: 014, P015: 015, P016: 016, P017: 017, P018: 018, P019: 019, + P020: 020, P021: 021, P022: 022, P023: 023, P024: 024, P025: 025, P026: 026, P027: 027, P028: 028, P029: 029, + P030: 030, P031: 031, P032: 032, P033: 033, P034: 034, P035: 035, P036: 036, P037: 037, P038: 038, P039: 039, + P040: 040, P041: 041, P042: 042, P043: 043, P044: 044, P045: 045, P046: 046, P047: 047, P048: 048, P049: 049, + P050: 050, P051: 051, P052: 052, P053: 053, P054: 054, P055: 055, P056: 056, P057: 057, P058: 058, P059: 059, + P060: 060, P061: 061, P062: 062, P063: 063, P064: 064, P065: 065, P066: 066, P067: 067, P068: 068, P069: 069, + P070: 070, P071: 071, P072: 072, P073: 073, P074: 074, P075: 075, P076: 076, P077: 077, P078: 078, P079: 079, + P080: 080, P081: 081, P082: 082, P083: 083, P084: 084, P085: 085, P086: 086, P087: 087, P088: 088, P089: 089, + P090: 090, P091: 091, P092: 092, P093: 093, P094: 094, P095: 095, P096: 096, P097: 097, P098: 098, P099: 099, + P100: 100, P101: 101, P102: 102, P103: 103, P104: 104, P105: 105, P106: 106, P107: 107, P108: 108, P109: 109, + P110: 110, P111: 111, P112: 112, P113: 113, P114: 114, P115: 115, P116: 116, P117: 117, P118: 118, P119: 119, + P120: 120, P121: 121, P122: 122, P123: 123, P124: 124, P125: 125, P126: 126, P127: 127, P128: 128, P129: 129, + P130: 130, P131: 131, P132: 132, P133: 133, P134: 134, P135: 135, P136: 136, P137: 137, P138: 138, P139: 139, + P140: 140, P141: 141, P142: 142, P143: 143, P144: 144, P145: 145, P146: 146, P147: 147, P148: 148, P149: 149, + P150: 150, P151: 151, P152: 152, P153: 153, P154: 154, P155: 155, P156: 156, P157: 157, P158: 158, P159: 159, + P160: 160, P161: 161, P162: 162, P163: 163, P164: 164, P165: 165, P166: 166, P167: 167, P168: 168, P169: 169, + P170: 170, P171: 171, P172: 172, P173: 173, P174: 174, P175: 175, P176: 176, P177: 177, P178: 178, P179: 179, + P180: 180, P181: 181, P182: 182, P183: 183, P184: 184, P185: 185, P186: 186, P187: 187, P188: 188, P189: 189, + P190: 190, P191: 191, P192: 192, P193: 193, P194: 194, P195: 195, P196: 196, P197: 197, P198: 198, P199: 199, + P200: 200, P201: 201, P202: 202, P203: 203, P204: 204, P205: 205, P206: 206, P207: 207, P208: 208, P209: 209, + P210: 210, P211: 211, P212: 212, P213: 213, P214: 214, P215: 215, P216: 216, P217: 217, P218: 218, P219: 219, + P220: 220, P221: 221, P222: 222, P223: 223, P224: 224, P225: 225, P226: 226, P227: 227, P228: 228, P229: 229, + P230: 230, P231: 231, P232: 232, P233: 233, P234: 234, P235: 235, P236: 236, P237: 237, P238: 238, P239: 239, + P240: 240, P241: 241, P242: 242, P243: 243, P244: 244, P245: 245, P246: 246, P247: 247, P248: 248, P249: 249, + P250: 250, P251: 251, P252: 252, P253: 253, P254: 254, P255: 255, P256: 256, P257: 257, P258: 258, P259: 259, + P260: 260, P261: 261, P262: 262, P263: 263, P264: 264, P265: 265, P266: 266, P267: 267, P268: 268, P269: 269, + P270: 270, P271: 271, P272: 272, P273: 273, P274: 274, P275: 275, P276: 276, P277: 277, P278: 278, P279: 279, + P280: 280, P281: 281, P282: 282, P283: 283, P284: 284, P285: 285, P286: 286, P287: 287, P288: 288, P289: 289, + P290: 290, P291: 291, P292: 292, P293: 293, P294: 294, P295: 295, P296: 296, P297: 297, P298: 298, P299: 299, + P300: 300, P301: 301, P302: 302, P303: 303, P304: 304, P305: 305, P306: 306, P307: 307, P308: 308, P309: 309, + P310: 310, P311: 311, P312: 312, P313: 313, P314: 314, P315: 315, P316: 316, P317: 317, P318: 318, P319: 319, + P320: 320, P321: 321, P322: 322, P323: 323, P324: 324, P325: 325, P326: 326, P327: 327, P328: 328, P329: 329, + P330: 330, P331: 331, P332: 332, P333: 333, P334: 334, P335: 335, P336: 336, P337: 337, P338: 338, P339: 339, + P340: 340, P341: 341, P342: 342, P343: 343, P344: 344, P345: 345, P346: 346, P347: 347, P348: 348, P349: 349, + P350: 350, P351: 351, P352: 352, P353: 353, P354: 354, P355: 355, P356: 356, P357: 357, P358: 358, P359: 359, + P360: 360, P361: 361, P362: 362, P363: 363, P364: 364, P365: 365, P366: 366, P367: 367, P368: 368, P369: 369, + P370: 370, P371: 371, P372: 372, P373: 373, P374: 374, P375: 375, P376: 376, P377: 377, P378: 378, P379: 379, + P380: 380, P381: 381, P382: 382, P383: 383, P384: 384, P385: 385, P386: 386, P387: 387, P388: 388, P389: 389, + P390: 390, P391: 391, P392: 392, P393: 393, P394: 394, P395: 395, P396: 396, P397: 397, P398: 398, P399: 399, + P400: 400, P401: 401, P402: 402, P403: 403, P404: 404, P405: 405, P406: 406, P407: 407, P408: 408, P409: 409, + P410: 410, P411: 411, P412: 412, P413: 413, P414: 414, P415: 415, P416: 416, P417: 417, P418: 418, P419: 419, + P420: 420, P421: 421, P422: 422, P423: 423, P424: 424, P425: 425, P426: 426, P427: 427, P428: 428, P429: 429, + P430: 430, P431: 431, P432: 432, P433: 433, P434: 434, P435: 435, P436: 436, P437: 437, P438: 438, P439: 439, + P440: 440, P441: 441, P442: 442, P443: 443, P444: 444, P445: 445, P446: 446, P447: 447, P448: 448, P449: 449, + P450: 450, P451: 451, P452: 452, P453: 453, P454: 454, P455: 455, P456: 456, P457: 457, P458: 458, P459: 459, + P460: 460, P461: 461, P462: 462, P463: 463, P464: 464, P465: 465, P466: 466, P467: 467, P468: 468, P469: 469, + P470: 470, P471: 471, P472: 472, P473: 473, P474: 474, P475: 475, P476: 476, P477: 477, P478: 478, P479: 479, + P480: 480, P481: 481, P482: 482, P483: 483, P484: 484, P485: 485, P486: 486, P487: 487, P488: 488, P489: 489, + P490: 490, P491: 491, P492: 492, P493: 493, P494: 494, P495: 495, P496: 496, P497: 497, P498: 498, P499: 499, + P500: 500, P501: 501, P502: 502, P503: 503, P504: 504, P505: 505, P506: 506, P507: 507, P508: 508, P509: 509, + P510: 510, P511: 511, P512: 512, P513: 513, P514: 514, P515: 515, P516: 516, P517: 517, P518: 518, P519: 519, + P520: 520, P521: 521, P522: 522, P523: 523, P524: 524, P525: 525, P526: 526, P527: 527, P528: 528, P529: 529, + P530: 530, P531: 531, P532: 532, P533: 533, P534: 534, P535: 535, P536: 536, P537: 537, P538: 538, P539: 539, + P540: 540, P541: 541, P542: 542, P543: 543, P544: 544, P545: 545, P546: 546, P547: 547, P548: 548, P549: 549, + P550: 550, P551: 551, P552: 552, P553: 553, P554: 554, P555: 555, P556: 556, P557: 557, P558: 558, P559: 559, + P560: 560, P561: 561, P562: 562, P563: 563, P564: 564, P565: 565, P566: 566, P567: 567, P568: 568, P569: 569, + P570: 570, P571: 571, P572: 572, P573: 573, P574: 574, P575: 575, P576: 576, P577: 577, P578: 578, P579: 579, + P580: 580, P581: 581, P582: 582, P583: 583, P584: 584, P585: 585, P586: 586, P587: 587, P588: 588, P589: 589, + P590: 590, P591: 591, P592: 592, P593: 593, P594: 594, P595: 595, P596: 596, P597: 597, P598: 598, P599: 599, + P600: 600, P601: 601, P602: 602, P603: 603, P604: 604, P605: 605, P606: 606, P607: 607, P608: 608, P609: 609, + P610: 610, P611: 611, P612: 612, P613: 613, P614: 614, P615: 615, P616: 616, P617: 617, P618: 618, P619: 619, + P620: 620, P621: 621, P622: 622, P623: 623, P624: 624, P625: 625, P626: 626, P627: 627, P628: 628, P629: 629, + P630: 630, P631: 631, P632: 632, P633: 633, P634: 634, P635: 635, P636: 636, P637: 637, P638: 638, P639: 639, + P640: 640, P641: 641, P642: 642, P643: 643, P644: 644, P645: 645, P646: 646, P647: 647, P648: 648, P649: 649, + P650: 650, P651: 651, P652: 652, P653: 653, P654: 654, P655: 655, P656: 656, P657: 657, P658: 658, P659: 659, + P660: 660, P661: 661, P662: 662, P663: 663, P664: 664, P665: 665, P666: 666, P667: 667, P668: 668, P669: 669, + P670: 670, P671: 671, P672: 672, P673: 673, P674: 674, P675: 675, P676: 676, P677: 677, P678: 678, P679: 679, + P680: 680, P681: 681, P682: 682, P683: 683, P684: 684, P685: 685, P686: 686, P687: 687, P688: 688, P689: 689, + P690: 690, P691: 691, P692: 692, P693: 693, P694: 694, P695: 695, P696: 696, P697: 697, P698: 698, P699: 699, + P700: 700, P701: 701, P702: 702, P703: 703, P704: 704, P705: 705, P706: 706, P707: 707, P708: 708, P709: 709, + P710: 710, P711: 711, P712: 712, P713: 713, P714: 714, P715: 715, P716: 716, P717: 717, P718: 718, P719: 719, + P720: 720, P721: 721, P722: 722, P723: 723, P724: 724, P725: 725, P726: 726, P727: 727, P728: 728, P729: 729, + P730: 730, P731: 731, P732: 732, P733: 733, P734: 734, P735: 735, P736: 736, P737: 737, P738: 738, P739: 739, + P740: 740, P741: 741, P742: 742, P743: 743, P744: 744, P745: 745, P746: 746, P747: 747, P748: 748, P749: 749, + P750: 750, P751: 751, P752: 752, P753: 753, P754: 754, P755: 755, P756: 756, P757: 757, P758: 758, P759: 759, + P760: 760, P761: 761, P762: 762, P763: 763, P764: 764, P765: 765, P766: 766, P767: 767, P768: 768, P769: 769, + P770: 770, P771: 771, P772: 772, P773: 773, P774: 774, P775: 775, P776: 776, P777: 777, P778: 778, P779: 779, + P780: 780, P781: 781, P782: 782, P783: 783, P784: 784, P785: 785, P786: 786, P787: 787, P788: 788, P789: 789, + P790: 790, P791: 791, P792: 792, P793: 793, P794: 794, P795: 795, P796: 796, P797: 797, P798: 798, P799: 799, + P800: 800, P801: 801, P802: 802, P803: 803, P804: 804, P805: 805, P806: 806, P807: 807, P808: 808, P809: 809, + P810: 810, P811: 811, P812: 812, P813: 813, P814: 814, P815: 815, P816: 816, P817: 817, P818: 818, P819: 819, + P820: 820, P821: 821, P822: 822, P823: 823, P824: 824, P825: 825, P826: 826, P827: 827, P828: 828, P829: 829, + P830: 830, P831: 831, P832: 832, P833: 833, P834: 834, P835: 835, P836: 836, P837: 837, P838: 838, P839: 839, + P840: 840, P841: 841, P842: 842, P843: 843, P844: 844, P845: 845, P846: 846, P847: 847, P848: 848, P849: 849, + P850: 850, P851: 851, P852: 852, P853: 853, P854: 854, P855: 855, P856: 856, P857: 857, P858: 858, P859: 859, + P860: 860, P861: 861, P862: 862, P863: 863, P864: 864, P865: 865, P866: 866, P867: 867, P868: 868, P869: 869, + P870: 870, P871: 871, P872: 872, P873: 873, P874: 874, P875: 875, P876: 876, P877: 877, P878: 878, P879: 879, + P880: 880, P881: 881, P882: 882, P883: 883, P884: 884, P885: 885, P886: 886, P887: 887, P888: 888, P889: 889, + P890: 890, P891: 891, P892: 892, P893: 893, P894: 894, P895: 895, P896: 896, P897: 897, P898: 898, P899: 899, + P900: 900, P901: 901, P902: 902, P903: 903, P904: 904, P905: 905, P906: 906, P907: 907, P908: 908, P909: 909, + P910: 910, P911: 911, P912: 912, P913: 913, P914: 914, P915: 915, P916: 916, P917: 917, P918: 918, P919: 919, + P920: 920, P921: 921, P922: 922, P923: 923, P924: 924, P925: 925, P926: 926, P927: 927, P928: 928, P929: 929, + P930: 930, P931: 931, P932: 932, P933: 933, P934: 934, P935: 935, P936: 936, P937: 937, P938: 938, P939: 939, + P940: 940, P941: 941, P942: 942, P943: 943, P944: 944, P945: 945, P946: 946, P947: 947, P948: 948, P949: 949, + P950: 950, P951: 951, P952: 952, P953: 953, P954: 954, P955: 955, P956: 956, P957: 957, P958: 958, P959: 959, + P960: 960, P961: 961, P962: 962, P963: 963, P964: 964, P965: 965, P966: 966, P967: 967, P968: 968, P969: 969, + P970: 970, P971: 971, P972: 972, P973: 973, P974: 974, P975: 975, P976: 976, P977: 977, P978: 978, P979: 979, + P980: 980, P981: 981, P982: 982, P983: 983, P984: 984, P985: 985, P986: 986, P987: 987, P988: 988, P989: 989, + P990: 990, P991: 991, P992: 992, P993: 993, P994: 994, P995: 995, P996: 996, P997: 997, P998: 998, P999: 999); + } + } } diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/Serialization/ConstructorTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/Serialization/ConstructorTests.cs index 54f5152845ebb..c76cad3658f48 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/Serialization/ConstructorTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/Serialization/ConstructorTests.cs @@ -140,6 +140,7 @@ protected ConstructorTests_Metadata(JsonSerializerWrapper stringWrapper) [JsonSerializable(typeof(LargeType_IgnoredProp_Bind_Param))] [JsonSerializable(typeof(ClassWithIgnoredSameType))] [JsonSerializable(typeof(ClassWithDefaultCtorParams))] + [JsonSerializable(typeof(ClassWithManyConstructorParameters))] internal sealed partial class ConstructorTestsContext_Metadata : JsonSerializerContext { } @@ -275,6 +276,7 @@ public ConstructorTests_Default(JsonSerializerWrapper jsonSerializer) : base(jso [JsonSerializable(typeof(LargeType_IgnoredProp_Bind_Param))] [JsonSerializable(typeof(ClassWithIgnoredSameType))] [JsonSerializable(typeof(ClassWithDefaultCtorParams))] + [JsonSerializable(typeof(ClassWithManyConstructorParameters))] internal sealed partial class ConstructorTestsContext_Default : JsonSerializerContext { }