As of version 3.1.1915.38 of Code Protector it is now possible to protect methods using generic code constructs. As with previous releases of Code Protector, it is not yet possible to protect generic methods or methods on a generic class; this capability will be delivered in a future release.
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
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.