Dependably determine collectibility in S.L.Expression's CanCache #25670
Conversation
Use RuntimeType.IsCollectible() to determine collectibility of types rather than only assuming those in mscorlib are not, which has many false positives (over 99% false positives in the uses Microsoft.CSharp makes of expressions). Build a delegate to make the call when IL generation is available, or use reflection directly when it is not.
Allows for the paths where CanCache returns false to be exercised, along letting the dynamic assemblies be collected, anyway.
If #25671 is accepted and implemented then it can replace the reflection used here. |
I agree that API like this would be a good idea. The format API review is required to expose API in the public contracts only. It is not needed to expose APIs from CoreLib that are used internally within other .NET Core assemblies that depend on CoreLib directly. I think you can go ahead and this API. It would be preferable to using private reflection. The private reflection does not work well for CoreRT/.NET Native UWP - I suspect that your current change is going to cause break there. |
Oh, I get you, I make it public in coreclr and corert but not in the refs. Thanks, @jkotas |
@jkotas A question on that in CoreRT, which I'm not familiar with at all (the only little bit of work I've done there was some very straight-forward copy-paste of some changes in CoreCLR). How does RuntimeType work there? I can't see anything equivalent, or equivalent to its |
RuntimeType is always non-collectible in CoreRT currently. |
This is the base of all RuntimeTypes in CoreRT: https://github.com/dotnet/corert/blob/master/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.cs |
Ah. I looked there but the lack of a comparable method confused me, when I shouldn't have been surprised it didn't need one. Thanks again, I'll hopefully get to this, this evening. |
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and dotnet/corefx#25670 Mirror PR to corert will need and overload making runtime types return false there.
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and dotnet/corefx#25670 Mirror PR to corert will need and overload making runtime types return false there.
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and dotnet/corefx#25670 Mirror PR to corert will need and overload making runtime types return false there. Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and dotnet/corefx#25670 Mirror PR to corert will need and overload making runtime types return false there. Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and dotnet/corefx#25670 Mirror PR to corert will need and overload making runtime types return false there.
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and #25670 Mirror PR to corert will need and overload making runtime types return false there. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and #25670 Mirror PR to corert will need and overload making runtime types return false there. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and #25670 Mirror PR to corert will need and overload making runtime types return false there. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
dotnet/corefx#25671 asks for this as a public API, but this just seeks to make it available to corefx. Motivation discussed at dotnet/corefx#25663 and #25670 Mirror PR to corert will need and overload making runtime types return false there. Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Use
RuntimeType.IsCollectible()
to determine collectibility of types rather than only assuming those in mscorlib are not, which has many false positives (over 99% false positives in the uses Microsoft.CSharp and System.Dynamic.Runtime make of expressions).Build a delegate to make the call when IL generation is available, or use reflection directly when it is not.
Allows for the paths where
CanCache
returns false to be exercised, along letting the dynamic assemblies be collected, anyway.