What is a source-only library?
Cement module requirements
Project requirements
Code-related practices
Change log
Sometimes there are classes that are needed in several libraries, but should not be exposed to consumers of those libraries. Such classes are grouped into source-only libraries: library projects with a Cement configuration in which all classes are marked internal and no build is performed. Dependent library projects then add links to the required source files from a source-only library instead of referencing an assembly.
In case the code in a source-only library is considered useful by itself, which is almost always, the library is built and published to NuGet like a usual Vostok library.
Source-only libraries are developed in much the same way as the usual Vostok libraries, so this document only covers things that are different for source-only libraries.
A Launchpad template can be found here. It's package is called Vostok.Launchpad.Templates.SourceLibrary.
- Every Cement module should have 3 configurations defined in
module.yaml
:src
where no build is performed.notests
which does not include unit tests and is a default configuration for Cement consumers.full-build
which inherits fromnotests
and includes unit tests.
- Cannot reference code from any other libraries.
- Every class or interface comprising library's public API must be marked internal and have
[PublicAPI]
attribute:
[PublicAPI]
internal class SampleClass { }
- Members with
[PublicAPI]
attribute are made public during build with code preprocessing MsBuild task
- 22.08.2018: source libs cannot reference any other libs
- 20.08.2018: source libs cannot reference other source libs
- 13.08.2018: replaced sample project link with launchpad template.
- 06.09.2019: conditional compilation for publicize replaced by code preprocessing