Skip to content

Commit

Permalink
disable C# 11 features temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
MaceWindu committed Nov 12, 2022
1 parent b85d748 commit 88a81a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ public static string ToSnakeCase(this string input)
if (string.IsNullOrEmpty(input))
return input;

var startUnderscores = UnderscoresMatcher().Match(input);
return startUnderscores + Replacer().Replace(input, "$1_$2").ToLowerInvariant();
var startUnderscores = UnderscoresMatcher.Match(input);
return startUnderscores + Replacer.Replace(input, "$1_$2").ToLowerInvariant();
}

[GeneratedRegex("^_+")]
private static partial Regex UnderscoresMatcher();
[GeneratedRegex("([a-z0-9])([A-Z])")]
private static partial Regex Replacer();
// TODO: uncomment after azure pipelines updated to 17.4
//[GeneratedRegex("^_+")]
//private static partial Regex UnderscoresMatcher();
//[GeneratedRegex("([a-z0-9])([A-Z])")]
//private static partial Regex Replacer();

#pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'.
private static readonly Regex UnderscoresMatcher = new ("^_+", RegexOptions.Compiled);
private static readonly Regex Replacer = new ("([a-z0-9])([A-Z])", RegexOptions.Compiled);
#pragma warning restore SYSLIB1045 // Convert to 'GeneratedRegexAttribute'.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public ExpressionReplacer(IDictionary<Expression, Expression> replaceMap)
_replaceMap = replaceMap ?? throw new ArgumentNullException(nameof(replaceMap));
}

[return: NotNullIfNotNull(nameof(node))]
// TODO: uncomment after azure pipelines updated to 17.4
//[return: NotNullIfNotNull(nameof(node))]
[return: NotNullIfNotNull("node")]
public override Expression? Visit(Expression? node)
{
if (node != null && _replaceMap.TryGetValue(node, out var replacement))
Expand Down
1 change: 0 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ stages:
displayName: 'Install .NET 7'
inputs:
version: 7.x
includePreviewVersions: true

- task: PowerShell@2
inputs:
Expand Down

0 comments on commit 88a81a7

Please sign in to comment.