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

[ActivatorUtilitiesConstructor] is dependent on constructor ordering #6959

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/DurationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ public class DurationType : StringToStructBaseType<Duration>
private readonly IPattern<Duration>[] _allowedPatterns;
private readonly IPattern<Duration> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="DurationType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public DurationType() : this(DurationPattern.Roundtrip)
{
}

/// <summary>
/// Initializes a new instance of <see cref="DurationType"/>.
/// </summary>
Expand All @@ -36,6 +28,14 @@ public DurationType(params IPattern<Duration>[] allowedPatterns) : base("Duratio
Description = NodaTimeResources.DurationType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="DurationType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public DurationType() : this(DurationPattern.Roundtrip)
{
}

/// <inheritdoc />
protected override string Serialize(Duration runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/InstantType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ public class InstantType : StringToStructBaseType<Instant>
private readonly IPattern<Instant>[] _allowedPatterns;
private readonly IPattern<Instant> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="InstantType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public InstantType() : this(InstantPattern.ExtendedIso)
{
}

/// <summary>
/// Initializes a new instance of <see cref="InstantType"/>.
/// </summary>
Expand All @@ -36,6 +28,14 @@ public InstantType(params IPattern<Instant>[] allowedPatterns) : base("Instant")
Description = NodaTimeResources.InstantType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="InstantType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public InstantType() : this(InstantPattern.ExtendedIso)
{
}

/// <inheritdoc />
protected override string Serialize(Instant runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/LocalDateTimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ public class LocalDateTimeType : StringToStructBaseType<LocalDateTime>
private readonly IPattern<LocalDateTime>[] _allowedPatterns;
private readonly IPattern<LocalDateTime> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="LocalDateTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public LocalDateTimeType() : this(LocalDateTimePattern.ExtendedIso)
{
}

/// <summary>
/// Initializes a new instance of <see cref="LocalDateTimeType"/>.
/// </summary>
Expand All @@ -36,6 +28,14 @@ public LocalDateTimeType(params IPattern<LocalDateTime>[] allowedPatterns) : bas
Description = NodaTimeResources.LocalDateTimeType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="LocalDateTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public LocalDateTimeType() : this(LocalDateTimePattern.ExtendedIso)
{
}

/// <inheritdoc />
protected override string Serialize(LocalDateTime runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/LocalDateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public class LocalDateType : StringToStructBaseType<LocalDate>
private readonly IPattern<LocalDate>[] _allowedPatterns;
private readonly IPattern<LocalDate> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="LocalDateType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public LocalDateType() : this(LocalDatePattern.Iso)
{
}

/// <summary>
/// Initializes a new instance of <see cref="LocalDateType"/>.
/// </summary>
Expand All @@ -37,6 +29,14 @@ public LocalDateType(params IPattern<LocalDate>[] allowedPatterns) : base("Local
Description = NodaTimeResources.LocalDateType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="LocalDateType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public LocalDateType() : this(LocalDatePattern.Iso)
{
}

/// <inheritdoc />
protected override string Serialize(LocalDate runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/LocalTimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public class LocalTimeType : StringToStructBaseType<LocalTime>
private readonly IPattern<LocalTime>[] _allowedPatterns;
private readonly IPattern<LocalTime> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="LocalTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public LocalTimeType() : this(LocalTimePattern.ExtendedIso)
{
}

/// <summary>
/// Initializes a new instance of <see cref="LocalTimeType"/>.
/// </summary>
Expand All @@ -37,6 +29,14 @@ public LocalTimeType(params IPattern<LocalTime>[] allowedPatterns) : base("Local
Description = NodaTimeResources.LocalTimeType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="LocalTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public LocalTimeType() : this(LocalTimePattern.ExtendedIso)
{
}

/// <inheritdoc />
protected override string Serialize(LocalTime runtimeValue)
=> _serializationPattern
Expand Down
22 changes: 11 additions & 11 deletions src/HotChocolate/Core/src/Types.NodaTime/OffsetDateTimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ public class OffsetDateTimeType : StringToStructBaseType<OffsetDateTime>
private readonly IPattern<OffsetDateTime>[] _allowedPatterns;
private readonly IPattern<OffsetDateTime> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="OffsetDateTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetDateTimeType() : this(OffsetDateTimePattern.ExtendedIso)
{
// Backwards compatibility with the original code's behavior
_serializationPattern = OffsetDateTimePattern.GeneralIso;
_allowedPatterns = [OffsetDateTimePattern.ExtendedIso,];
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetDateTimeType"/>.
/// </summary>
Expand All @@ -40,6 +29,17 @@ public OffsetDateTimeType(params IPattern<OffsetDateTime>[] allowedPatterns)
Description = NodaTimeResources.OffsetDateTimeType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetDateTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetDateTimeType() : this(OffsetDateTimePattern.ExtendedIso)
{
// Backwards compatibility with the original code's behavior
_serializationPattern = OffsetDateTimePattern.GeneralIso;
_allowedPatterns = [OffsetDateTimePattern.ExtendedIso,];
}

/// <inheritdoc />
protected override string Serialize(OffsetDateTime runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/OffsetDateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ public class OffsetDateType : StringToStructBaseType<OffsetDate>
private readonly IPattern<OffsetDate>[] _allowedPatterns;
private readonly IPattern<OffsetDate> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="OffsetDateType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetDateType() : this(OffsetDatePattern.GeneralIso)
{
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetDateType"/>.
/// </summary>
Expand All @@ -38,6 +30,14 @@ public OffsetDateType(params IPattern<OffsetDate>[] allowedPatterns) : base("Off
Description = NodaTimeResources.OffsetDateType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetDateType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetDateType() : this(OffsetDatePattern.GeneralIso)
{
}

/// <inheritdoc />
protected override string Serialize(OffsetDate runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/OffsetTimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public class OffsetTimeType : StringToStructBaseType<OffsetTime>
private readonly IPattern<OffsetTime>[] _allowedPatterns;
private readonly IPattern<OffsetTime> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="OffsetTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetTimeType() : this(OffsetTimePattern.GeneralIso)
{
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetTimeType"/>.
/// </summary>
Expand All @@ -37,6 +29,14 @@ public OffsetTimeType(params IPattern<OffsetTime>[] allowedPatterns) : base("Off
Description = NodaTimeResources.OffsetTimeType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetTimeType() : this(OffsetTimePattern.GeneralIso)
{
}

/// <inheritdoc />
protected override string Serialize(OffsetTime runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/OffsetType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ public class OffsetType : StringToStructBaseType<Offset>
private readonly IPattern<Offset>[] _allowedPatterns;
private readonly IPattern<Offset> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="OffsetType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetType() : this(OffsetPattern.GeneralInvariantWithZ)
{
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetType"/>.
/// </summary>
Expand All @@ -38,6 +30,14 @@ public OffsetType(params IPattern<Offset>[] allowedPatterns) : base("Offset")
Description = NodaTimeResources.OffsetType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="OffsetType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public OffsetType() : this(OffsetPattern.GeneralInvariantWithZ)
{
}

/// <inheritdoc />
protected override string Serialize(Offset runtimeValue)
=> _serializationPattern
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/PeriodType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public class PeriodType : StringToClassBaseType<Period>
private readonly IPattern<Period>[] _allowedPatterns;
private readonly IPattern<Period> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="PeriodType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public PeriodType() : this(PeriodPattern.Roundtrip)
{
}

/// <summary>
/// Initializes a new instance of <see cref="PeriodType"/>.
/// </summary>
Expand All @@ -37,6 +29,14 @@ public PeriodType(params IPattern<Period>[] allowedPatterns) : base("Period")
Description = NodaTimeResources.PeriodType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="PeriodType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public PeriodType() : this(PeriodPattern.Roundtrip)
{
}

/// <inheritdoc />
protected override string Serialize(Period runtimeValue)
=> _serializationPattern.Format(runtimeValue);
Expand Down
16 changes: 8 additions & 8 deletions src/HotChocolate/Core/src/Types.NodaTime/ZonedDateTimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ public class ZonedDateTimeType : StringToStructBaseType<ZonedDateTime>
private readonly IPattern<ZonedDateTime>[] _allowedPatterns;
private readonly IPattern<ZonedDateTime> _serializationPattern;

/// <summary>
/// Initializes a new instance of <see cref="ZonedDateTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public ZonedDateTimeType() : this(_default)
{
}

/// <summary>
/// Initializes a new instance of <see cref="ZonedDateTimeType"/>.
/// </summary>
Expand All @@ -43,6 +35,14 @@ public ZonedDateTimeType(params IPattern<ZonedDateTime>[] allowedPatterns)
Description = NodaTimeResources.ZonedDateTimeType_Description;
}

/// <summary>
/// Initializes a new instance of <see cref="ZonedDateTimeType"/>.
/// </summary>
[ActivatorUtilitiesConstructor]
public ZonedDateTimeType() : this(_default)
{
}

/// <inheritdoc />
protected override string Serialize(ZonedDateTime runtimeValue)
=> _serializationPattern
Expand Down
24 changes: 12 additions & 12 deletions src/HotChocolate/Core/src/Types.Scalars.Upload/UploadType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ namespace HotChocolate.Types;
/// </summary>
public class UploadType : ScalarType<IFile, FileValueNode>
{
/// <summary>
/// Initializes a new instance of the <see cref="UploadType"/> class.
/// </summary>
[ActivatorUtilitiesConstructor]
public UploadType()
: this(
"Upload",
UploadResources.UploadType_Description,
BindingBehavior.Implicit)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="UploadType"/> class.
/// </summary>
Expand All @@ -33,6 +21,18 @@ public UploadType(
Description = description;
}

/// <summary>
/// Initializes a new instance of the <see cref="UploadType"/> class.
/// </summary>
[ActivatorUtilitiesConstructor]
public UploadType()
: this(
"Upload",
UploadResources.UploadType_Description,
BindingBehavior.Implicit)
{
}

public override IValueNode ParseResult(object? resultValue)
{
if (resultValue is null)
Expand Down
Loading
Loading