As of Code Protector 3.1.1915 it is possible to protect methods using generic code constructs. It is not yet possible to protect generic methods or methods on a generic class; this capability will be delivered in a future release.
[Note: An explanation of the technical terms used within this document can be found at http://msdn.microsoft.com/en-us/library/aa479859.aspx]
So you may now use the following generic constructs in protected code:
- Declaring variables of closed constructed generic types, such as List<string>, List<List<int>> etc.
- Calling methods on closed constructed generic types
class GenericClass { void M(T a){} // parameter of generic class argument type void N(List a){} // parameter of constructed generic type using generic class argument type } //inside a protected method... var a = new GenericClass(); a.M("Hello World!"); // allowed
- Calling closed generic methods, i.e. methods whose type arguments do not contain any generic parameters e.g.
class NormalClass { void M(T a){} // parameter of generic method argument type void N(List a){} // parameter of constructed generic type using generic method argument type } //inside a protected method... var a = new NormalClass(); a.M("Hello World!"); // allowed a.N(new List(){"Hello", "World", "!"}; // allowed, type inferred
- Calling generic methods that have overloads declared on the same type with the same number of generic type parameters and method parameters e.g.
class NormalClass { void M(Func a){} void M(List a){} } //inside protected method... var a = new NormalClass(); a.M(() => "Hello World!")// allowed a.N(new List(){"Hello", "World", "!"}; // allowed
Comments
0 comments
Article is closed for comments.