https://github.com/dpvreony/syntixi
Source generator to embed SyncFusion License Key from an environment variable
https://github.com/dpvreony/syntixi
roslyn-generator syncfusion
Last synced: 4 months ago
JSON representation
Source generator to embed SyncFusion License Key from an environment variable
- Host: GitHub
- URL: https://github.com/dpvreony/syntixi
- Owner: dpvreony
- License: mit
- Created: 2024-06-11T18:44:11.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2026-03-07T07:49:32.000Z (4 months ago)
- Last Synced: 2026-03-07T15:00:29.826Z (4 months ago)
- Topics: roslyn-generator, syncfusion
- Language: C#
- Homepage:
- Size: 234 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: citation.cff
Awesome Lists containing this project
README
# Syntixi
## Mission Statement
* To provide a mechanism to embed Syncfusion license keys into applications as part of the build process.
## Introduction
Syntixi is a Roslyn Source Generator that picks up the license key in a way that:
* allows the key to not be stored in source control
* allows the embedding without the direct modification of the source code, again preventing the risk of the key accidentally ending up in source control.
* Syncfusion has a couple of batch scripts that can be embedded into your csproj but these do alter the source code and do it a slightly blind fashion.
## Getting Started
You will need a Syncfusion license key
### 1. Create an application (such as WPF)
### 2. Add a nuget package reference to "Syntixi.Attributes" and "Syntixi.SourceGenerator" in your project
```xml
all
runtime; build; native; contentfiles; analyzers; buildtransitive
```
This will add an attributes package and the source generator package. NOTE: if you don't include the build assets for the SourceGenerator it will not make the props file available that allows Roslyn to access the SyncFusion environment variable \ secret.
### 3. Add the following initialisation for the Syncfusion license manager
```cs
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(SYNCFUSION_LICENSE_KEY);
```
### 4. Mark the class hosting the logic as partial and add the attribute to the class
```cs
///
/// WPF Application entry point.
///
[Syntixi.Attributes.EmbedSyncfusionLicenseKey]
public partial class App : Application
{
// YOUR CODE HERE
}
```
### 5. Add the license key to a CI secret or your local environment variables.
???
## longer examples
### Full example that will fail if the license key isn't present
The source generator is written to set a Diagnostic Error if the attribute is included but the license key isn't present in the environment.
```cs
///
/// WPF Application entry point.
///
[Syntixi.Attributes.EmbedSyncfusionLicenseKey]
public partial class App : Application
{
///
/// Initializes a new instance of the class.
///
public App()
{
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(SYNCFUSION_LICENSE_KEY);
}
}
```
### Full example that will not include the Syncfusion license manager if they license key isn't present.
The source generator has a .props file includes the compiler directive `SYNTIXI_SYNCFUSION_LICENSE_KEY`.
```cs
///
/// WPF Application entry point.
///
#if SYNTIXI_SYNCFUSION_LICENSE_KEY
[Syntixi.Attributes.EmbedSyncfusionLicenseKey]
#endif
public partial class App : Application
{
///
/// Initializes a new instance of the class.
///
public App()
{
#if SYNTIXI_SYNCFUSION_LICENSE_KEY
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(SYNCFUSION_LICENSE_KEY);
#endif
}
}
```
## Viewing the documentation
The documentation can be found at https://docs.dpvreony.com/projects/syntixi/
## Contributing to the code
See the [contribution guidelines](CONTRIBUTING.md).