For quite obvious reasons it makes sense to obfuscate all references to classes, methods ans properties from Windows.Services.Store
, namespace.
The troubles are caused by async methods. Consider, for example the following code:
var info = await context.GetAppLicenseAsync();
Since the method returns IAsyncOperation<StoreAppLicense>
, it can be obfuscated as the following:
string mehtodName=decode("UnreadableName"); // Returns "GetAppLicenseAsync"
var info = await (IAsyncOperation<StoreAppLicense>)
context.GetType().GetRuntimeMethod(methodName, new Type[0]).
Invoke(context, new object[0]);
However class StoreAppLicense is still used in casting, and I can't find a way to obfuscate it. As far as I know, C# generic doesn't allow "any class" (similar to <?>
in Java)in Java), while IAsyncOperation<object>
gives a casting error.
There is away to create (generic) type IAsyncOperation<StoreAppLicense>
, but how can I cast to it? This forum and some others have pages for casting to reflected type, but some provide methods (like Convert.ChangeType or Type.TryCast) which are unavailable with UWP, others effectively suggesti to avoid cast. How the cast can be avoided in this case? Suprisingly Type class has method IsAssignableFrom
, but no method Assign
. Any ideas?
Aucun commentaire:
Enregistrer un commentaire