Search code examples
c#.netresharperridernullable-reference-types

How to put "#nullable" after using (import) block after code reformat


How to say to Rider (Resharper) put #nullable after using (import) block after code reformat?

My example:

  • Preconditions:
    • JetBrains Rider 2022.1.2. I expect the same results with Resharper because Rider and Resharper use the same settings.
    • File with content:
using System.Collections.Generic;

#nullable enable

internal record Response
{
    public IList<decimal>? Items { get; init; }
}
  • Steps:
    1. Choose the file in solution explorer
    2. Context menu -> Refactor this -> Move to folder

Actual result:

  • #nullable enable was moved before using (import) block.
#nullable enable

using System.Collections.Generic;

internal record Response
{
    public IList<decimal>? Items { get; init; }
}

Expected result:

  • File content did not change.

Solution

  • I played around with both Rider and R# and was not able to produce your desired behavior. So I assume that's not yet supported 😕

    Maybe you can create a ticket at JetBrains so that they can track it as a feature request.