C
C#7mo 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
333fred7mo ago
That method cannot be inserted by the compiler Are you certain you're not just seeing the effects of inlining?
n8ta
n8ta7mo ago
@333fred that could be happening. Is there a good way to tell from the dll?
333fred
333fred7mo ago
That is a runtime thing The DLL has nothing to do with it
n8ta
n8ta7mo 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
More Posts
Does anyone know how to fix the last part of this code?while (true) { var frame = videoReader.ReadVideoFrame(); What is a good way of loading and unloading an assembly at runtime?im making a system that should be able to load an assembly, run code from it, and then be able to unEFCore 8 - Owned type with navigation property not being includedHello, i have an issue with EFCore (or maybe it's just me being pepega), but i have a class Score thSqlBulkCopy IListWhat frameworks are available for performing bulk copy using an `IList` as the input? There's `DataUsing base class as relationship definition in model ASP.net WEB APISo I've written this model that I used to save my credentials to authenticate my users with: ```cshhow to join will null?I have this logic: ```cs private async Task OnChannelsGet( IDeliveryHandlerContext context, ✅ Ensure that subclasses all have to override a specific method?Is it possible to define a method in a class to say that it *must* be defined in every subclass? FoAnyone from Ukraine here? Recommend any remote Ukrainan/russian speaking companies for junior/mediorAnyone from Ukraine here? Recommend any remote Ukrainan/russian speaking companies for junior/medior✅ WPF Datagrid colums widthHi, any idea why my column do not fit the whole width of my datagrid ? https://paste.mod.gg/csupsvqClass library is not found while building the ASP.NET Core 7 Web API with Github ActionsI wrote this dotnet.yml to build my application and push the docker image to docker hub, placed in t