C
C#11mo ago
n8ta

✅ How does this code call System.Text.StringBuilder.ToString?

public bool PersistSettings()
{
bool succeeded = false;

try
{
lock (thisLock)
{
if (!hasChanges)
{
return true;
}

BackupSettingsFile();

using (StreamWriter writer = new StreamWriter(settingsFile))
{
writer.Write(JsonConvert.SerializeObject(settings));
}

hasChanges = false;
succeeded = true;
}
}
catch (Exception e)
{
RestoreSettingsFile();
}

return succeeded;
}
public bool PersistSettings()
{
bool succeeded = false;

try
{
lock (thisLock)
{
if (!hasChanges)
{
return true;
}

BackupSettingsFile();

using (StreamWriter writer = new StreamWriter(settingsFile))
{
writer.Write(JsonConvert.SerializeObject(settings));
}

hasChanges = false;
succeeded = true;
}
}
catch (Exception e)
{
RestoreSettingsFile();
}

return succeeded;
}
I've grabbed stacks of my program at runtime and I can see it in the PersistSettings method and then above that on the stack is System.Text.StringBuilder.ToString. Can anyone tell where that method could be inserted by the compiler?
4 Replies
333fred
333fred11mo ago
That method cannot be inserted by the compiler Are you certain you're not just seeing the effects of inlining?
n8ta
n8taOP11mo ago
@333fred that could be happening. Is there a good way to tell from the dll?
333fred
333fred11mo ago
That is a runtime thing The DLL has nothing to do with it
n8ta
n8taOP11mo ago
@333fred gotcha. I don't see any super shallow paths where it could be inlined but I'm not sure how else it could occur
Want results from more Discord servers?
Add your server