[204] Error on blueprint with localized name (easy fix)

Digi shared this bug 45 days ago
Reported

The fix is going to be way easier than explaining the issue because it requires a few things to line up, but the reproduction is easy too at least with the included sbc.

First the stacktrace:

MOD PARTIALLY SKIPPED, LOADED ONLY 2/6 PHASES, Following Error occured:
Input string was not in a correct format.
mscorlib
   at System.Text.StringBuilder.FormatError()
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at Sandbox.Definitions.MyBlueprintDefinitionBase.ToString()
   at System.String.Concat(Object[] args)
   at Sandbox.Definitions.MyDefinitionManager.InitBlueprints(MyModContext context, Dictionary`2 output, DefinitionDictionary`1 blueprintsByResult, MyObjectBuilder_BlueprintDefinition[] blueprints, Boolean failOnDebug)
...
The issue is in MyBlueprintDefinitionBase.ToString() as it doesn't use the string format to insert new data but instead it concats and that causes the issue. I'd get rid of string.Format() everywhere as it's prone to runtime issues like this, compared to string interpolation where it's checked at compile time.


I attached a local mod to reproduce with, place in SE appdata's Mods folder, create an empty world and add that mod to it, then load it. You'll see F11 menu popping up with the critical error on it.

Replies (1)

photo
1

Hello Digi,

Thank you for reaching our forum and letting us know about this issue.

Issue was successfully reproduced on our side and put into our internal system.

Kind Regards,

Keen Software House: QA Department

Leave a Comment
 
Attach a file