You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InvaildCastException occurs when the argument is passed in as a collection expression #1729
InvaildCastException occurs when the argument is passed in as a collection expression
传入参数为集合表达式时会发生 InvaildCastException
To Reproduce
Compositor. CreateEffectFactory() have multiple overloaded method, one of the second parameter for IEnumerable, at this time if in the second parameter to set expression directly, causing InvaildCastException
Compositor.CreateEffectFactory() 方法有多个重载,其中一个第二个参数为 IEnumerable,这时如果在第二个参数中直接传入集合表达式,引发 InvaildCastException
Expected behavior
Provide warning or support collection expression in parameter
Version Info
CsWinRT 2.1.1
Windows SDK 10.0.26100.0
.NET SDK 9.0.0-preview7
Additional context
Found in the process of debugging, set the type of the expression is <>z_ReadOnlySingleElementList
调试的过程中,发现集合表达式生成的类型是<>z_ReadOnlySingleElementList
Manodasan Wignarajah (@manodasanW) I think we should not use source generator at the first place, instead we should generate an assembly just like what WPF does, so that things like this can get covered.
Sergio did bring up a related idea with separate assembly for the generic instantiations and vtable lookup table that is being considered. But I don't think that would solve this problem where these are internal .NET types that CsWinRT won't directly be aware of unless you were thinking of something there?
The plan to address that is to make use of the statically known interface on the projection and provide a vtable for that when the one for the class isn't available. This is tracked by #1661. The tricky part will be minimizing size impact.
Activity
hez2010 commentedon Sep 3, 2024
Manodasan Wignarajah (@manodasanW) I think we should not use source generator at the first place, instead we should generate an assembly just like what WPF does, so that things like this can get covered.
manodasanW commentedon Sep 4, 2024
Sergio did bring up a related idea with separate assembly for the generic instantiations and vtable lookup table that is being considered. But I don't think that would solve this problem where these are internal .NET types that CsWinRT won't directly be aware of unless you were thinking of something there?
The plan to address that is to make use of the statically known interface on the projection and provide a vtable for that when the one for the class isn't available. This is tracked by #1661. The tricky part will be minimizing size impact.
Sergio0694 commentedon Nov 26, 2024
Manodasan Wignarajah (@manodasanW) pretty sure this should be fixed with 2.2, right? It's just passing a
List<string>explicitly 🤔