Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make public API predicated on "DOCOPTNET_PUBLIC" #79

Merged
merged 1 commit into from
Apr 5, 2021

Conversation

atifaziz
Copy link
Collaborator

@atifaziz atifaziz commented Apr 5, 2021

While PR #76 had the nice side-effect enabling source-embedding, it also meant that the public API would leak into the parent project. This PR enables private embedding scenarios easily without any additional effort. It does so by marking all type definitions in the DocoptNet project as being partial and moves the public modifier for those types to Public.cs (the only exception is the ValueType enumeration since partial is not allowed on enum). What's more, Public.cs is entirely predicated on the conditional compilation symbol DOCOPTNET_PUBLIC being defined. The overall effect of this is that if anyone embeds the sources then they'll get private embedding by default; they won't unknowingly leak anything into their project's public API (unless of course DOCOPTNET_PUBLIC is defined in the host project but that would have to be an intentional action).

The source generator in PR #77 will benefit from this as I currently embed DocoptNet sources into the source generator project:

<ItemGroup>
  <Compile Include="..\DocoptNet\*.cs" Link="DocoptNet\%(Filename)" />
</ItemGroup>

In this PR, I removed Extensions from being public since I think StringPartition (before PR #69) should have been public in the first place. I also removed the internal modifier from all types for sake of consistency since that's the default in C# anyhow.


PS Like PR #76, this PR sort-of adds to #8.

This enables private embedding-scenarios.
@atifaziz atifaziz requested a review from voieducode April 5, 2021 10:50
@voieducode voieducode merged commit 3b70613 into docopt:master Apr 5, 2021
@atifaziz atifaziz deleted the conditional-public-api branch April 5, 2021 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants