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
// Check for non-deterministic TimeProvider methods: GetUtcNow, GetLocalNow, GetTimestamp
108
+
boolisNonDeterministicMethod=invokedMethod.Nameis"GetUtcNow" or "GetLocalNow" or "GetTimestamp";
109
+
110
+
if(isNonDeterministicMethod)
111
+
{
112
+
// e.g.: "The method 'Method1' uses 'System.TimeProvider.GetUtcNow()' that may cause non-deterministic behavior when invoked from orchestration 'MyOrchestrator'"
// e.g: "Use 'context.CurrentUtcDateTime' instead of 'DateTime.Now'"
58
+
// e.g: "Use 'context.CurrentUtcDateTime.Date' instead of 'DateTime.Today'"
59
+
// e.g: "Use '(DateTimeOffset)context.CurrentUtcDateTime' instead of 'DateTimeOffset.Now'"
60
+
stringtitle=string.Format(
61
+
CultureInfo.InvariantCulture,
62
+
Resources.UseInsteadFixerTitle,
63
+
recommendation,
64
+
dateTimeExpression);
65
+
66
+
context.RegisterCodeFix(
67
+
CodeAction.Create(
68
+
title:title,
69
+
createChangedDocument: c =>ReplaceDateTime(context.Document,orchestrationContext.Root,dateTimeExpression,contextParameterName,isDateTimeToday,isDateTimeOffset),
70
+
equivalenceKey:title),// This key is used to prevent duplicate code fixes.
// e.g: "Use 'context.CurrentUtcDateTime' instead of 'TimeProvider.System.GetUtcNow()'"
100
+
stringtitle=string.Format(
101
+
CultureInfo.InvariantCulture,
102
+
Resources.UseInsteadFixerTitle,
103
+
recommendation,
104
+
timeProviderInvocation);
58
105
59
-
// e.g: "Use 'context.CurrentUtcDateTime' instead of 'DateTime.Now'"
60
-
// e.g: "Use 'context.CurrentUtcDateTime.Date' instead of 'DateTime.Today'"
61
-
// e.g: "Use '(DateTimeOffset)context.CurrentUtcDateTime' instead of 'DateTimeOffset.Now'"
62
-
stringtitle=string.Format(
63
-
CultureInfo.InvariantCulture,
64
-
Resources.UseInsteadFixerTitle,
65
-
recommendation,
66
-
dateTimeExpression.ToString());
67
-
68
-
context.RegisterCodeFix(
69
-
CodeAction.Create(
70
-
title:title,
71
-
createChangedDocument: c =>ReplaceDateTime(context.Document,orchestrationContext.Root,dateTimeExpression,contextParameterName,isDateTimeToday,isDateTimeOffset),
72
-
equivalenceKey:title),// This key is used to prevent duplicate code fixes.
73
-
context.Diagnostics);
106
+
context.RegisterCodeFix(
107
+
CodeAction.Create(
108
+
title:title,
109
+
createChangedDocument: c =>ReplaceTimeProvider(context.Document,orchestrationContext.Root,timeProviderInvocation,contextParameterName,methodName,returnsDateTimeOffset),
0 commit comments