Skip to content

Commit ef56e34

Browse files
committed
Fix CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
1 parent 150eb26 commit ef56e34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiClient.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ public void RegisterDocument(object document, AlwaysIncludedAttributes alwaysInc
137137

138138
Type documentType = document.GetType();
139139

140-
if (!_documentsByType.ContainsKey(documentType))
140+
if (!_documentsByType.TryGetValue(documentType, out ISet<object>? documents))
141141
{
142-
_documentsByType[documentType] = new HashSet<object>();
142+
documents = new HashSet<object>();
143+
_documentsByType[documentType] = documents;
143144
}
144145

145-
_documentsByType[documentType].Add(document);
146+
documents.Add(document);
146147
}
147148

148149
public void UnRegisterDocument(object document)

0 commit comments

Comments
 (0)