Comments (24)
At some point I'll draft a spec, or someone else could if they feel inclined, and start a PR. Im not sure when I'll have time just yet.
from myriad.
What I wanted to make sure of was that complexity didn't explode, once you add two ways of doing things the logic starts to twist, we would have 3 ways of invoking a plugin, and three ways of specifying the properties which all have to end up being CLI params.
from myriad.
This is done, just need docs 😢
from myriad.
Currently the CLI input has mandatory input so that would have to be addressed first: https://github.com/MoiraeSoftware/myriad/blob/master/src/Myriad/Program.fs#L14
Actual the MSBuild target property is also mandatory too.
plugins are included via the msbuild injection of props from the nuget generator.props
etc.
So its the plugin author who decides if a plugin is applied or not.
from myriad.
Interesting.. So now I see how you are binding the Plugin arg from MSBuild to CLI here:
<MyriadSdk_Args Include='--plugin %(MyriadSdkGenerator.FullPath)' Condition=" '@(MyriadSdkGenerator)' != '' "/>
That is passing the plugin .dll path to the Myriad CLI -- which I am doing that here in SqlHydra.props.
But I have multiple generators in my plugin dll, so then how can it know which to use?
Is MSBuild going to try to execute all of the generators it finds in my dll?
Can more than one ItemGroup
be configured within a single project? (like if I wanted to use two different plugins in the same project)?
EDIT:
Sorry, I guess I can answer that question for myself by looking at your very clean CLI code!
from myriad.
All plugins in a dll will get called, fields/dus/lend all share the same dll
from myriad.
Gotcha. Sorry, I was referring to generators as plugins which was adding to the confusion.
All generators get called on build.
from myriad.
So then let me try again:
Would it make sense to be able to specify a MyriadGenerator
since a plugin dll can have multiple generators?
<ItemGroup>
<!-- Specify the .fs output file (to be generated by Myriad) -->
<Compile Include="AdventureWorks.fs">
<!-- Specify the .dacpac input file -->
<MyriadFile>../AdventureWorks/bin/Debug/AdventureWorks.dacpac</MyriadFile>
<MyriadGenerator>ssdt<MyriadPlugin>
</Compile>
</ItemGroup>
from myriad.
But I have multiple generators in my plugin dll, so then how can it know which to use?
Thats a good question when theres no input file, the addition of validExtension was added as part of that filter for input files that didn't have a way of attributing what needed generating, I think input file could be empty is the CLI argument was non mandatory and the msbuild condition was removed. I think some sort of modulation of the props might be needed, I did once thing that having key/values in the msbuild could be useful but hoped the toml config might be better.
Compile.MyriadFile
Compile.Myriad.File
Having Myriad as the basic element might make more sense now that fs/any/none could be valid input types
from myriad.
<ItemGroup>
<!-- Specify the .fs output file (to be generated by Myriad) -->
<Compile Include="AdventureWorks.fs">
<!-- Specify the .dacpac input file -->
<Myriad>
<InputFile>../AdventureWorks/bin/Debug/AdventureWorks.dacpac</MyriadFile>
<Generator>
<Name>ssdt</Name>
<Namespace>test</Namespace>
</Generator>
<!-- Or just text element -->
<Generator>other</Generator>
<Myriad>
</Compile>
</ItemGroup>```
Theres also using the toml file to add all these extra pieces of info:
<ItemGroup>
<!-- Specify the .fs output file (to be generated by Myriad) -->
<Compile Include="AdventureWorks.fs">
<!-- Specify the .dacpac input file -->
<Myriad>
<Generator>
<Config>myGeneratorSection</Config>
</Generator>
<Myriad>
</Compile>
</ItemGroup>
from myriad.
I think maybe extending the interface so that IsValid is passed some properties and then the plugin author can decide whether its applied of not
IsValid(inputFile: string option, extension: string option, generators: string list) : bool
generators
would probably be exclusive if present I guess its up to the plugin to decide based on the inputs passed
from myriad.
It could also be possible to specify a glob as part of an filename to tell the generator what to do like [id].fs
which would give it a one to many output. Im thinking too far ahead anyway, need to reign it in :-)
from myriad.
The clarity of intent is really high in this example you posted above. I like it!
<ItemGroup>
<Compile Include="AdventureWorks.fs">
<Myriad>
<InputFile>../AdventureWorks/bin/Debug/AdventureWorks.dacpac</InputFile>
<Generator>ssdt</Generator>
<Myriad>
</Compile>
</ItemGroup>
Things I like about it:
- It doesn't need my comments anymore because it's very obvious that Myriad will be generating the file, and it's obvious that all the elements within
<Myriad>
are configuration settings. <InputFile>
has more clear intent than<MyriadFile>
(which isn't immediately obvious whether it is for input or output). This is less an issue in my scenario since the input is a .dacpac, but worse if both input and output are .fs files.- It would allow specifying a named generator in the case where no input file is needed
- Moving Namespace configuration into here seems pretty convenient. Although, the toml is already pretty straight forward and flexible.
from myriad.
I think maybe extending the interface so that IsValid is passed some properties and then the plugin author can decide whether its applied of not
IsValid(inputFile: string option, extension: string option, generators: string list) : bool
generators
would probably be exclusive if present I guess its up to the plugin to decide based on the inputs passed
The IsValid
filter is also a very nice idea. It seems like maybe it could even replace the ValidInputExtensions
member altogether since it has the extension
passed to it.
I like that inputFile
is optional. I'm not sure how generators
would work so I have opinion on it.
from myriad.
<InputFile>
has more clear intent than (which isn't immediately obvious whether it is for input or output). This is less an issue in my scenario since the input is a .dacpac, but worse if both input and output are .fs files.
Its to do with how msbuild work, output file is Compile Include, it has to be that way to get any integration
Technically it could just be <Input>{ ... }</Input>
with inline data which is output, I think the file suffix is a bit wordy. Having Myriad
as the parent makes it obvious that the siblings are just for it.
from myriad.
I think making the input optional and adding explicit Generators after this:
https://github.com/MoiraeSoftware/myriad/blob/master/src/Myriad.Sdk/build/Myriad.Sdk.targets#L8
Is probably the way to proceed.
from myriad.
@JordanMarr Im not entirely sure what the conclusion of all this was?
from myriad.
Maybe its: There needs to be a way of specifying which generators do or don't run on arbitrary files, so some type of filter, and as it cant be in the file itself it needs to be in the fsproj, hence the need for a generator and maybe an exludeGenerator element?
<Compile Include="ArbitaryFile.fs">
<MyriadFile>Test.txt</MyriadFile>
<MyriadConfigKey>example1</MyriadConfigKey>
<MyriadParams>
<MyriadParam1>5</MyriadParam1>
<MyriadParam2>6</MyriadParam2>
</MyriadParams>
</Compile>
Thats what an arbitrary input file currently supports
from myriad.
I ended up shelving the .dacpac approach entirely because:
- .dacpac is limited to only SQL Server and I opted to support multiple DB providers
- I already implemented .dacpac support for SQLProvider anyway
So you can probably close the issue... that is unless you still want to add support for specifying a generator for a given Compile
output file (which does seem like it would be useful). I think a filter is exactly what is needed: run all by default unless one or more <Generator>ssdt</Generator>
elements are specified, in which case it would only use those.
Or if you wanted to go all out, you could even make <IncludeGenerator>ssdt</IncludeGenerator>
and <ExcludeGenerator>ssdt<ExcludeGenerator>
which would make it a little more explicitly additive or subtractive, but that may also be overkill.
from myriad.
It does feel like a feature hole where everything just runs, especially if you like to cram multiple plugins in one dll.
from myriad.
What makes it hard is this needs to be done in msbuild otherwise every plugin always gets activated and has to return an empty ast so nothing is added but thats very wasteful, the plugin should just not get invoked by myriad if it is excluded.
from myriad.
Thinking more I don't think its even possible at the MSBuild level as Myriad uses reflection to find all plugins inside the passed dll, so it has to be done at that point which is annoying.
from myriad.
Or you could just throw a few lines into the readme and be done with it.
from myriad.
CAnt remember anything about this, so closing...
from myriad.
Related Issues (20)
- Add batching API so state can be passed amongst plugins of the same type HOT 3
- [docs] How to build the docs pages locally? HOT 5
- TOSO: Rip Docsy theme the fuck out.
- Myriad di deploy di server mana? app.myriad.social HOT 1
- Did myriad letters are supported as superscript?
- Allow inline generation with custom placement HOT 15
- Allow generating lenses with module instead of namespace, or without either HOT 8
- Memoise the calls to toml get configuration HOT 1
- Extensions like SynType.Option generate incorrect syntax HOT 1
- Upgrading from 0.5.0 to 0.8.1 removes keywords from many elements HOT 12
- Can we have a release please? ;) HOT 3
- Plugin path not quoted HOT 1
- Automatic generation of record variant types HOT 5
- Change log link in nugget has no version
- Readme missing from nugget package
- Working on invalid syntax HOT 2
- Generate output based on multiple input files HOT 6
- Documentation on how to create my own plugin? HOT 2
- The "Terms of use" in the README seems to violate the Open Source Definition. HOT 2
- New nuget version with Fantomas upgrade HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from myriad.