Code analysis rules fail because of shifted enum in ScriptDOM
We have written some code analysis rules to detect problems with our code (see https://github.com/XtendBusinessSoftware/XtendDacRules).
This works with Visual Studio 2019, but in Visual Studio 2022 some rules report everything as an error.
We looked into this and it turns out that the enum that we are checking values against has changed where someone added extra values in the middle (see https://github.com/microsoft/SqlScriptDOM/blob/main/SqlScriptDom/Parser/TSql/TSqlTokenTypes.g line 268 to 271 for the new values. This file is used to generate the enum if I understand it correctly).
We are checking if we have the right token by coding the below C# code (see https://github.com/XtendBusinessSoftware/XtendDacRules/blob/master/XtendDacRules/XtendDacRules/UnusedVariableVisitor.cs line 47 and 48):
TSqlParserToken token = stream[i];
if (token.TokenType == TSqlTokenType.Variable)
Is this the wrong way to write this? The alternative seems to be check the string version of the values, but this seems nasty.
I would have thought it is a bad idea to add new values in a public enum. It will also be difficult to keep one version of our rules that works on both Visual Studio 2019 and 2022 (and any future versions) if this keeps happening.