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

Fix extra minus sign when formatting -0 on .NET Core 3.0 #1790

Merged
merged 1 commit into from
Nov 5, 2019

Conversation

Chicken-Bones
Copy link
Contributor

.NET Core fixed some round trip formatting with floats https://devblogs.microsoft.com/dotnet/floating-point-parsing-and-formatting-improvements-in-net-core-3-0/

When decompiling -0f on .NET Core, ILSpy currently outputs --0f which is a compile error. Simplest reproducible test case:

using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.TypeSystem;
using System;
using System.Linq;
using System.Reflection;

namespace DecompilerTesting
{
    class Program
    {
        static void Main(string[] args)
        {
            var decompiler = new CSharpDecompiler(Assembly.GetExecutingAssembly().Location, new DecompilerSettings());
            var method = decompiler.TypeSystem.MainModule.GetTypeDefinition(new TopLevelTypeName("DecompilerTesting.Program")).GetMethods(m => m.Name == "MinusZero").Single();
            decompiler.Decompile(method.MetadataToken).AcceptVisitor(new CSharpOutputVisitor(Console.Out, FormattingOptionsFactory.CreateAllman()));
        }

        public static float MinusZero() => -0f;
    }
}

@dgrunwald dgrunwald merged commit 31dbce2 into icsharpcode:master Nov 5, 2019
ElektroKill added a commit to dnSpyEx/ILSpy that referenced this pull request Aug 2, 2021
Fix extra minus sign when formatting -0 on .NET Core 3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants