Skip to content

Commit aa6efce

Browse files
committed
Use TryGetValue
1 parent 5537d79 commit aa6efce

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpDiagnosticClassifier.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ public MissingXamarinSdkRule() :
4242

4343
public override void Fire(DiagnosticClassifier classifier, Match match)
4444
{
45-
if (!match.Groups.ContainsKey("sdkName"))
45+
if (!match.Groups.TryGetValue("sdkName", out var sdkName))
4646
throw new ArgumentException("Expected regular expression match to contain sdkName");
4747

48-
var sdkName = match.Groups["sdkName"].Value;
4948
var xamarinResults = classifier.Results.OfType<Result>().Where(result =>
50-
result.SDKName.Equals(sdkName)
49+
result.SDKName.Equals(sdkName.Value)
5150
);
5251

5352
if (!xamarinResults.Any())
54-
classifier.Results.Add(new Result(sdkName));
53+
classifier.Results.Add(new Result(sdkName.Value));
5554
}
5655
}
5756

0 commit comments

Comments
 (0)