Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const string reference replaced by string literal value #3222

Open
Aussiemon opened this issue Jun 14, 2024 · 0 comments
Open

Const string reference replaced by string literal value #3222

Aussiemon opened this issue Jun 14, 2024 · 0 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@Aussiemon
Copy link

Aussiemon commented Jun 14, 2024

Similar to #1084.

The reference to const kPlantableNameKey is replaced by its value in the constructor, which is valid code, but an unused assignment / variable warning at the IDE. Perhaps the decompiler could check for private constants and replace matching literals in scope, or perhaps this is a more specific edge case.

Input code

public class TestDecomp
{
	private const string kPlantableNameKey = "Chamomile";

	public string GetPlantableNameKey()
	{
		return kPlantableNameKey;
	}
}

Erroneous output (from .NET 8.0 SDK class library)

public class TestDecomp
{
	private const string kPlantableNameKey = "Chamomile";

	public string GetPlantableNameKey()
	{
		return "Chamomile";
	}
}

Details

  • Product in use: ILSpy
  • Version in use: ILSpy 9.0 Preview 2
@Aussiemon Aussiemon added Bug Decompiler The decompiler engine itself labels Jun 14, 2024
@Aussiemon Aussiemon changed the title Const string value replaced by string literal Const string reference replaced by string literal value Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

1 participant