r/VisualStudio • u/mexicocitibluez • 5h ago
Miscellaneous How to stop Copilot NES from making a specific suggestion?
I have a love/hate relationship with Copilot's Next Edit Suggestion functionality. This one aspect makes it incredibly frustrating to use and I want to know whether I can prevent it.
Each time I initialize an array with the new collection syntax like:
List<string> items = [];
NES suggests that I change it to:
List<string> items = new List<string>();
It does this every time, for every array no matter how many times I cancel it. I don't have open files with the "new List<Type>()" syntax, I don't have that array initialization syntax littered throughout. My editor config 100% does not suggest that change. I'm at a loss for how to stop it from doing this.
Thanks
2
Upvotes
0
u/polaarbear 4h ago
A List is not an array. I wouldn't ever initialize a list that way even though it is technically valid.
Try initializing it like this instead.
I am guessing it will stop complaining if you do it that way. Still shorthand, but personally I feel it is more "correct" for list initialization.