I have written a code analyzer by using Roslyn APIs. The analyzer search for the hardcoded Urls in the code and fails the compilation of the code.
For example:
public class{
public static string demo = "https://demo.com";
}
My analyser will fail the compilation of the above code saying it found the hard coded Url in the code.
There are some scenarios in which i want the analyzer to ignore the hardcoded urls error(in case its completely mandatory for the user to use it).
Is there anyway by which i will be able to give analyzer the signal to ignore the hardcoded Url.
I thought of using something like this:
public class{
#region IGNORE HARDCODED URLS
public static string demo = "https://demo.com";
#endregion
}
But the problem with this approach is that i am unable to get all the variable declared inside the region IGNORE HARDCODED URLS.
Questions:
1.) Is this approach of using regions seems good for the use-case i am trying to solve? Is there any other better solutions you guys can think of and provide?
2.) If my approach looks good, then can somebody tell me how to get all the variables declared in the particular region?