Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

CodeFormatter should not rename private fields that are part of an interop type. #230

Open
ghost opened this issue Apr 20, 2016 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 20, 2016

C# structs that are designed to map to known C++ structures for the purposes of P/Invoke'ing are expected to have names that match the original C++ names. CodeFormatter should not add an "_" to those fields, even if the field's visibility is "private."

Two reasons I might put "private" on such a field:

  • It represents a union field and I choose to hide it and replace them with strongly typed properties that validate or assert the union discriminator.
  • It represents an obscure/dangerous/hard-to-marshal field that I know my library doesn't reference so I choose to mark it NYOB and have the "private" visibility enforce that.

A good rule for deciding whether a struct is an "interop type" might be to check if the author explicitly added the [StructLayout(Sequential/Explicit)] tag the struct.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants