This project is read-only.

Refactor providers ordering

Topics: APIs, General
May 29, 2014 at 11:04 PM
Can the order in which refactor providers are listed in the smart tag somehow influenced, either by user or the provider's developer?

I am asking because the order I am getting is not consistent and I want one of the providers to be always the first one so that simply pressing Alt+., Enter just executes that very one...
Jun 5, 2014 at 4:16 PM
You can use the [Order] attribute on your ICodeRefactoringProvider, and set the "Before" to be the standard items. This is the standard mechanism for ordering in VS editor extensions.
Jun 5, 2014 at 4:52 PM
Great, that looks like what I was looking for. Is there any special value for After/Before to bring the provider after or before all the standard items? Because I guess you need to put the extension type name in there.
Jun 5, 2014 at 5:00 PM
No, we don't have a special name.

Internally, we have Microsoft.CodeAnalysis.CodeRefactorings.PredefinedCodeRefactoringProviderNames, which contains the names of our providers, but nothing exposed publicly.