lundi 19 mars 2018

How can I correctly parse SuppressMessage's Target value?

I want to remove SuppressMessage items from my GlobalSuppressions.cs file where their target no-longer exists (e.g. because it was renamed or its signature changed).

I'm writing a program to do this for me automatically: It will read the Target="" values and load the Assembly and check to see if the class/type or member still exists.

Unfortunately the Target="" values are not using the normal syntax for types and members. For example, I have this signature in my C# source:

protected Boolean SetParameter<T>(String propertyName, ref T field, T newValue)

But it appears in my GlobalSuppressions.cs file like this:

Target = "MyNamespace.MyClass.#SetParameter`1(System.String,!!0&,!!0)" )]

In my program, I have the System.Reflection.MethodInfo (RuntimeMethodInfo) for my SetParameter method and it reports its name is:

`Boolean SetParameter[T](System.String, T ByRef, T)`

...which doesn't match either.





Aucun commentaire:

Enregistrer un commentaire