-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3179 from vweijsters/fix-3160
Workaround for issue #3160
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DictionaryExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
namespace StyleCop.Analyzers.Helpers | ||
{ | ||
using System.Collections.Generic; | ||
|
||
internal static class DictionaryExtensions | ||
{ | ||
public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue) | ||
where TKey : notnull | ||
{ | ||
if (!dictionary.TryGetValue(key, out var value)) | ||
{ | ||
value = defaultValue; | ||
} | ||
|
||
return value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters