Skip to content

Codefix for suppress <ID> in Source inserts pragma restore before semicolon #26015

@JohanLarsson

Description

@JohanLarsson

Code before:

namespace RoslynSandbox
{
    public class Foo
    {
        public Foo()
        {
        var text = @"Line 1
Line 2";
        }
    }
}

Fixed code:

namespace RoslynSandbox
{
    public class Foo
    {
        public Foo()
        {
#pragma warning disable CS0219 // Variable is assigned but its value is never used
            var text = @"Line 1
Line 2"
#pragma warning restore CS0219 // Variable is assigned but its value is never used
;
        }
    }
}

I would prefer
Fixed code:

namespace RoslynSandbox
{
    public class Foo
    {
        public Foo()
        {
#pragma warning disable CS0219 // Variable is assigned but its value is never used
            var text = @"Line 1
Line 2";
#pragma warning restore CS0219 // Variable is assigned but its value is never used
        }
    }
}

The example uses the code fix to suppress CS0219

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions