Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ private void GenCases(LoggerMethod lm, string nestedIndentation)
{
// 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)}),");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ private static HttpEndPointListener GetEPListener(string host, int port, HttpLis
}

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
{
Expand All @@ -146,9 +146,9 @@ private static HttpEndPointListener GetEPListener(string host, int port, HttpLis
}

HttpEndPointListener? epl;
if (p.ContainsKey(port))
if (p.TryGetValue(port, out HttpEndPointListener? epListener))
{
epl = p[port];
epl = epListener;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ private static void NewKnownStack (Dictionary<int, Stack<StackSlot>> knownStacks
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 ()));
}
Expand Down Expand Up @@ -292,12 +292,12 @@ protected virtual void Scan (MethodIL methodIL, ref InterproceduralState interpr
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);
}
}

Expand Down