Skip to content

DefaultInterpolatedStringHandler #405

@Orden4

Description

@Orden4

As of .NET 6, interpolated strings get compiled into a rather convoluted construct, like so:

// original
return $"{this.saveFolder}\\{GetPlayerName(player)}-save-{saveSlot}{this.suffix}.pld"

// compiled
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(11, 4);
defaultInterpolatedStringHandler.AppendFormatted(saveFolder);
defaultInterpolatedStringHandler.AppendLiteral("\\");
defaultInterpolatedStringHandler.AppendFormatted(Common.GetPlayerName(player));
defaultInterpolatedStringHandler.AppendLiteral("-save-");
defaultInterpolatedStringHandler.AppendFormatted(saveSlot);
defaultInterpolatedStringHandler.AppendFormatted(suffix);
defaultInterpolatedStringHandler.AppendLiteral(".pld");
return defaultInterpolatedStringHandler.ToStringAndClear();

This code won't work when transpiled because DefaultInterpolatedStringHandler isn't implemented in CSharpLua.
Normally speaking this wouldn't be a problem, but my WCSharp library is utilised by having War3Net decompile the NuGet packages and then transpiling them to Lua, which means that the code that gets used is not the code that I directly wrote, but the decompiled code.

I've raised the topic with the creator of War3Net as well over on Hiveworkshop, but I imagine that the best solution is if DefaultInterpolatedStringHandler gets implemented in CSharpLua.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions