BindingListView icon indicating copy to clipboard operation
BindingListView copied to clipboard

Dynamic comparison functions under .NET 5.0

Open ATECoder opened this issue 3 years ago • 6 comments

It looks like the dynamic code generation for comparison generates an invalid IL code. I tried this for the Foo example for sorting on the Abscissa. The function private static Comparison<T> BuildValueTypeComparison( PropertyInfo pi, ListSortDirection direction ) returns in invalid IL code.

ATECoder avatar Mar 02 '21 20:03 ATECoder

Hi @AteCoder Sorry, I don't maintain this code anymore and I haven't used it in years. Feel free to make a fork and fix it up - I'll be glad to put a link in this repo's README to point to yours.

waynebloss avatar Mar 04 '21 06:03 waynebloss

Hi @waynebloss thank you for your reply.

Could you give me a hint on how I can see the IL that is created by the BuildValueTypeComparison function? I can than compare the 4.72 and 5.0 code and report this to MS.

ATECoder avatar Mar 04 '21 18:03 ATECoder

@AteCoder Here's the code that generates the intermediate language - https://github.com/waynebloss/BindingListView/blob/ae7143356c7d3a49e4b3434bf09ffbc8d401fb44/src/BindingListView/AggregateBindingListView.cs#L1478

Here's some info on how to debug it:

  • https://stackoverflow.com/questions/321203/how-do-i-debug-il-code-generated-at-runtime-using-reflection-emit
  • https://stackoverflow.com/questions/56043204/is-there-a-way-to-view-dynamicmethod-resulting-x86-assembly-code
  • https://www.google.com/search?q=.net+DynamicMethod+GetILGenerator+debug+il

waynebloss avatar Mar 05 '21 02:03 waynebloss

Super! I'll give it a shot.

ATECoder avatar Mar 05 '21 02:03 ATECoder

Hi @AteCoder Sorry, I don't maintain this code anymore and I haven't used it in years. Feel free to make a fork and fix it up - I'll be glad to put a link in this repo's README to point to yours.

Hi @wayneblooss. Why did you stop keeping it? Or do you use another tool?

danielvega avatar May 31 '21 22:05 danielvega

@danielvega I don't do a lot of WinForms anymore. Mostly I am doing web and mobile frontends, if any...

waynebloss avatar May 31 '21 23:05 waynebloss