-
-
Notifications
You must be signed in to change notification settings - Fork 8
Best Practices
Jeff Campbell edited this page Jun 14, 2021
·
2 revisions
The types a DataProvider
can inspect can be limited to a subset by taking advantage of the AssembliesConfig
. This enables a plugin to limit types inspected to only those from certain assemblies.
This feature can be used by implementing IConfigurable
and use AssembliesConfig
to acquire the config settings for which assemblies should be searched if enabled.
Example Implementation
/// <inheritdoc />
public CodeGeneratorData[] GetData()
{
var codeGenData = new List<CodeGeneratorData>();
var filteredTypeSymbols =
_assembliesConfig.FilterTypeSymbols(_memoryCache.GetNamedTypeSymbols());
codeGenData.AddRange(GetFactoryCodeGeneratorData(filteredTypeSymbols));
codeGenData.AddRange(GetFactoryEnumCodeGeneratorData(filteredTypeSymbols));
return codeGenData.ToArray();
}
In order to easily iterate on custom Genesis plugins, I will often add a post-build copy step to the C# assembly project they are contained in so that whenever built they will be automatically included with the installation. The snippet below would be added as a child element of the root Project
XML element.
<Target Name="CopyBuildArtifacts" AfterTargets="Build">
<ItemGroup>
<DataFiles Include="$(ProjectDir)$(OutDir)**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(DataFiles)" DestinationFolder="$(ProjectDir)..\..\GenesisCLI\Plugins\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>