Hugh
✅ Ensure that subclasses all have to override a specific method?
What I've now done is made sure that all of the non-abstract classes are sealed, and where I was subclassing a class that could also be instanced, I've made a shared abstract base class with a sealed subclass.
8 replies
Using ILGenerator to create and populate a List<string>
Looking into it a little further, I believe that the
!0
in the parameter type list for Add
just refers to it being the first generic type argument (i.e. string). A different IL viewer shows that line as:
3 replies
Using ILGenerator to create and populate a List<string>
I've marked where I think the error is. If I'm creating an empty list, and I skip the code between the
set list members
comments, it works fine.
My feeling is that the issue is something to do with the (!0)
at the end. I'm not sure what I would do to make this. I've tried changing the potential issue lines to:
which does the same thing as just doing il.Call
. I've also tried passing in an array of a single typeof(string)
instead of null
, but in that situation it says Calling convention must be VarArgs
Any idea how I can re-create this IL dynamically?3 replies
✅ Setting default values on fields when generating runtime type
(these are running in two processes, and I want to be able to only have some types defined in one of the processes, but able to be passed through the other - these two examples are the two ends of the processes)
10 replies
✅ Setting default values on fields when generating runtime type
I guess if this is all dealt with in the constructor, that answers my follow-up question, which is how to determine what the default value is in a compiler-time type - I had thought I was doing this a hacky way by creating an instance and then querying it, but I guess that's how this should be done
10 replies