0

What is a verifiable type in C#?

I am reading the CLR via C# book. And I come across the following piece of knowledge data:

It should be noted that it is illegal to define a type in which a reference type and a value type overlap. It is possible to define a type in which multiple reference types overlap at the same starting offset; however, this is unverifiable. It is legal to define a type in which multiple value types overlap; however, all of the overlapping bytes must be accessible via public fields for the type to be verifiable.

The piece is related to the System.Runtime.InteropServices.StructLayoutAttribute attribute and the System.Runtime.InteropServices.FieldOffsetAttribute attribute. It is about the Layout of a Type’s Fields.

I can not find on the internet the definition of a verifiable type, are there any?

UPDATE

In the comments section below the following question was pointed out: this.

So, according to the answer I assume that a type is verifiable if any manipulations with the fields and the methods of the type do not break the CLR functionality. It is a roughly speaking definition, but is it correct?

qqqqqqq
  • 1,831
  • 1
  • 18
  • 48
  • 1
    Possible duplicate of this (see the answer not the question): https://stackoverflow.com/questions/4533471/what-is-verifiable-managed-assembly – Ross Gurbutt Nov 17 '19 at 14:07
  • @RossGurbutt, thank you. I will update my question. – qqqqqqq Nov 17 '19 at 16:20
  • @RossGurbutt, should I remove my question from your pov? Or do you think that it is possible to get a useful info from an answer if it will be provided? – qqqqqqq Nov 17 '19 at 16:24
  • I'd leave it here in case anyone else needs the information. If someone with the ability to mark it as a duplicate thinks that's correct / wants to then they can. – Ross Gurbutt Nov 17 '19 at 16:28
  • @RossGurbutt, great. Thank you. – qqqqqqq Nov 17 '19 at 16:29
  • Also, it's not to do with breaking CLR functionality so much as just the possibility to execute unsafe code. – Ross Gurbutt Nov 17 '19 at 16:29

0 Answers0