Make public API predicated on "DOCOPTNET_PUBLIC" #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thepublic
modifier for those types toPublic.cs
(the only exception is theValueType
enumeration sincepartial
is not allowed onenum
). What's more,Public.cs
is entirely predicated on the conditional compilation symbolDOCOPTNET_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 courseDOCOPTNET_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:
In this PR, I removed
Extensions
from being public since I thinkStringPartition
(before PR #69) should have been public in the first place. I also removed theinternal
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.