- To provide a mechanism to embed Syncfusion license keys into applications as part of the build process.
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.
You will need a Syncfusion license key
<ItemGroup>
<PackageReference Include="Syntixi" Version="1.0.0" />
</ItemGroup>
This will add an attributes package and the source generator package.
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(SYNCFUSION_LICENSE_KEY);
/// <summary>
/// WPF Application entry point.
/// </summary>
[Syntixi.Attributes.EmbedSyncfusionLicenseKey]
public partial class App : Application
{
// YOUR CODE HERE
}
???
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.
/// <summary>
/// WPF Application entry point.
/// </summary>
[Syntixi.Attributes.EmbedSyncfusionLicenseKey]
public partial class App : Application
{
/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
/// </summary>
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
.
/// <summary>
/// WPF Application entry point.
/// </summary>
#if SYNTIXI_SYNCFUSION_LICENSE_KEY
[Syntixi.Attributes.EmbedSyncfusionLicenseKey]
#endif
public partial class App : Application
{
/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
/// </summary>
public App()
{
#if SYNTIXI_SYNCFUSION_LICENSE_KEY
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(SYNCFUSION_LICENSE_KEY);
#endif
}
}
The documentation can be found at https://docs.dpvreony.com/projects/syntixi/
See the contribution guidelines.