{
// this is related to https://github.com/serilog/serilog-extensions-logging/issues/197
string name = p.CodeName;
- if (lm.TemplateMap.ContainsKey(name))
+ if (lm.TemplateMap.TryGetValue(name, out string value))
{
// take the letter casing from the template
- name = lm.TemplateMap[name];
+ name = value;
}
_builder.AppendLine($" {nestedIndentation}{index++} => new global::System.Collections.Generic.KeyValuePair<string, object?>(\"{name}\", this.{NormalizeSpecialSymbol(p.CodeName)}),");
}
Dictionary<int, HttpEndPointListener>? p;
- if (s_ipEndPoints.ContainsKey(addr))
+ if (s_ipEndPoints.TryGetValue(addr, out Dictionary<int, HttpEndPointListener>? value))
{
- p = s_ipEndPoints[addr];
+ p = value;
}
else
{
}
HttpEndPointListener? epl;
- if (p.ContainsKey(port))
+ if (p.TryGetValue(port, out HttpEndPointListener? epListener))
{
- epl = p[port];
+ epl = epListener;
}
else
{
return;
}
- if (knownStacks.ContainsKey (newOffset)) {
- knownStacks[newOffset] = MergeStack (knownStacks[newOffset], newStack);
+ if (knownStacks.TryGetValue (newOffset, out Stack<StackSlot>? value)) {
+ knownStacks[newOffset] = MergeStack (value, newStack);
} else {
knownStacks.Add (newOffset, new Stack<StackSlot> (newStack.Reverse ()));
}
foreach (Instruction operation in methodIL.Instructions) {
int curBasicBlock = blockIterator.MoveNext (operation);
- if (knownStacks.ContainsKey (operation.Offset)) {
+ if (knownStacks.TryGetValue (operation.Offset, out Stack<StackSlot>? knownValue)) {
if (currentStack == null) {
// The stack copy constructor reverses the stack
- currentStack = new Stack<StackSlot> (knownStacks[operation.Offset].Reverse ());
+ currentStack = new Stack<StackSlot> (knownValue.Reverse ());
} else {
- currentStack = MergeStack (currentStack, knownStacks[operation.Offset]);
+ currentStack = MergeStack (currentStack, knownValue);
}
}