Overview
I want my usings in the following order:
- System
- Microsoft
- 3rd Party packages
- My own namespaces
- using static namespaces
To achieve this I created 5 groups, 4 of which are trivial, because they are simply StatsWith and constant value. However in order to place all 3rd party package usings I tried to use a regex, which does not match any of the other groups.
When I used the hotkey to format the usings the 3rd party ones were ordered last, When I opened the settings again I was intrigued to see that my group rule is completely gone. So I tested it:
- Create a new rule, chose
MatchRegex and pass in ^[^.]+?(using (?!System)(?!Microsoft)(?!Interactive\.)(?!static)[A-Z]{1}.*)$ as Value - Save settings
- Use format hotkey
- Open settings again
The newly created rule is gone.
This does not happen for all regex values. For example the rule did not go away with .+?using AutoMapper;.
Sample namespaces I tested with:
usingMicrosoft.AspNetCore.Mvc;usingAutoMapper;usingInteractive.Servers.Controllers;usingInteractive.Servers.Extensions;usingMicrosoft.Extensions.Logging;usingInteractive.Servers.Lms.Models;usingSystem.Threading.Tasks;usingInteractive.Servers.Lms.Models.Exams;usingInteractive.Services.Lms.Business;usingstaticInteractive.Servers.ServerConstants;usingInteractive.Services.Mapping;
Overview
I want my usings in the following order:
To achieve this I created 5 groups, 4 of which are trivial, because they are simply
StatsWithand constant value. However in order to place all 3rd party package usings I tried to use a regex, which does not match any of the other groups.When I used the hotkey to format the usings the 3rd party ones were ordered last, When I opened the settings again I was intrigued to see that my group rule is completely gone. So I tested it:
MatchRegexand pass in^[^.]+?(using (?!System)(?!Microsoft)(?!Interactive\.)(?!static)[A-Z]{1}.*)$asValueThe newly created rule is gone.
This does not happen for all regex values. For example the rule did not go away with
.+?using AutoMapper;.Sample namespaces I tested with: