Is there a way to create a custom quick fix suggestion? Follow Daa82 Created May 31, 2017 18:59 For example, I would like all PUBLIC const/static read-only fields to be placed in a "Constants.cs" file. Is there a way to do that?
Yes, you can write a plugin that can look for public const or static fields, highlight them with a warning or suggestion, and then attach a Quick Fix to this warning. The quick fix would need to rewrite your code to remove the field and add it back into Constants.cs, and then fix up any existing references. This is a lot of work, so it might be better to invoke the Move refactoring to do that for you.
You can find more information on creating a plugin in the developer guide, with details on how to add a highlight and how to create a Quick Fix. The docs for Quick Fixes are a little out of date, although mostly still correct. You can see an example in the Unity plugin. The Unity plugin also has an example of how to invoke a refactoring programmatically, although it's invoking the Change Signature fix. The principle is the same.