You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (OperandType == typeof(global::System.TimeSpan))
386
+
{
387
+
if (!global::System.TimeSpan.TryParse((string)Minimum, culture, out global::System.TimeSpan timeSpanMinimum) ||
388
+
!global::System.TimeSpan.TryParse((string)Maximum, culture, out global::System.TimeSpan timeSpanMaximum))
389
+
{
390
+
throw new global::System.InvalidOperationException(c_minMaxError);
391
+
}
392
+
Minimum = timeSpanMinimum;
393
+
Maximum = timeSpanMaximum;
394
+
}
395
+
else
396
+
{
397
+
Minimum = ConvertValue(Minimum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
398
+
Maximum = ConvertValue(Maximum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
399
+
}
400
+
"""
401
+
:
402
+
"""
403
+
Minimum = ConvertValue(Minimum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
404
+
Maximum = ConvertValue(Maximum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
405
+
""";
406
+
407
+
stringconvertValue=emitTimeSpanSupport?
408
+
"""
409
+
if (OperandType == typeof(global::System.TimeSpan))
410
+
{
411
+
if (value is global::System.TimeSpan)
412
+
{
413
+
convertedValue = value;
414
+
}
415
+
else if (value is string)
416
+
{
417
+
if (!global::System.TimeSpan.TryParse((string)value, formatProvider, out global::System.TimeSpan timeSpanValue))
418
+
{
419
+
return false;
420
+
}
421
+
convertedValue = timeSpanValue;
422
+
}
423
+
else
424
+
{
425
+
throw new global::System.InvalidOperationException($"A value type {value.GetType()} that is not a TimeSpan or a string has been given. This might indicate a problem with the source generator.");
catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
Minimum = ConvertValue(Minimum, culture) ?? throw new global::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
429
-
Maximum = ConvertValue(Maximum, culture) ?? throw new global::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
501
+
{{initializationString}}
430
502
}
431
503
int cmp = ((global::System.IComparable)Minimum).CompareTo((global::System.IComparable)Maximum);
432
504
if (cmp > 0)
@@ -448,14 +520,7 @@ public override bool IsValid(object? value)
catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
EmitRangeAttribute(_optionsSourceGenContext.ClassModifier,Emitter.StaticAttributeClassNamePrefix,attributeData.Key,_optionsSourceGenContext.Suffix,attributeData.Valueis not null);
(constructorParameters.Length!=3||typeSymbol.SpecialType==argumentSpecialType))// When type is provided as a parameter, it has to match the property type.
Copy file name to clipboardExpand all lines: src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Baselines/EmitterWithCustomValidator.netcore.g.cs
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -99,19 +99,21 @@ public override string FormatErrorMessage(string name) =>
Minimum=ConvertValue(Minimum,culture)??thrownewglobal::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
114
-
Maximum=ConvertValue(Maximum,culture)??thrownewglobal::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
Copy file name to clipboardExpand all lines: src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Baselines/EmitterWithCustomValidator.netfx.g.cs
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -97,19 +97,21 @@ public override string FormatErrorMessage(string name) =>
Minimum=ConvertValue(Minimum,culture)??thrownewglobal::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
112
-
Maximum=ConvertValue(Maximum,culture)??thrownewglobal::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
0 commit comments