mirror of
https://github.com/Smaug123/WoofWare.Whippet
synced 2025-10-06 00:08:39 +00:00
Enable suppression of plugins (#16)
This commit is contained in:
@@ -70,6 +70,10 @@ through the `Parameters` field on the plugin's args.
|
||||
(MSBuild only allows strings here, so the `"true"` in the above example is a string, not a boolean.
|
||||
If you want more advanced inputs to your plugin, you will have to create a parser yourself.)
|
||||
|
||||
You can supply `<WhippetSuppressPlugin>JsonSerializeGenerator,JsonParseGenerator</WhippetSuppressPlugin>` (for example) next to `<WhippetFile>`
|
||||
to suppress on that file the action of all of the specified comma-separated list of generators.
|
||||
(That is, we will ignore any generator defined in a class with one of these names.)
|
||||
|
||||
## Standalone tool
|
||||
|
||||
The standalone tool takes the following arguments:
|
||||
|
@@ -19,6 +19,8 @@ type WhippetTarget =
|
||||
InputSource : FileInfo
|
||||
GeneratedDest : FileInfo
|
||||
Params : Map<string, string>
|
||||
/// Suppress plugins with any of these names.
|
||||
Suppress : string Set
|
||||
}
|
||||
|
||||
module Program =
|
||||
@@ -131,6 +133,11 @@ module Program =
|
||||
)
|
||||
|> Map.ofSeq
|
||||
|
||||
let suppress =
|
||||
Map.tryFind "WhippetSuppressPlugin" metadata
|
||||
|> Option.map (fun s -> s.Split ',' |> Set.ofArray)
|
||||
|> Option.defaultValue Set.empty
|
||||
|
||||
let inputSource =
|
||||
FileInfo (Path.Combine (Path.GetDirectoryName desiredProject.ProjectFileName, myriadFile))
|
||||
|
||||
@@ -143,6 +150,7 @@ module Program =
|
||||
GeneratedDest = generatedDest
|
||||
InputSource = inputSource
|
||||
Params = pars
|
||||
Suppress = suppress
|
||||
}
|
||||
|> Some
|
||||
)
|
||||
@@ -179,14 +187,20 @@ module Program =
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
pluginDll, applicablePlugins
|
||||
pluginAssembly, applicablePlugins
|
||||
)
|
||||
|
||||
for item in toGenerate do
|
||||
use output = item.GeneratedDest.Open (FileMode.Create, FileAccess.Write)
|
||||
use outputWriter = new StreamWriter (output, leaveOpen = true)
|
||||
|
||||
for _, applicablePlugins in plugins do
|
||||
let plugins =
|
||||
plugins
|
||||
|> Seq.map (fun (_, plugins) ->
|
||||
plugins |> List.filter (fun (ty, _) -> not (Set.contains ty.Name item.Suppress))
|
||||
)
|
||||
|
||||
for applicablePlugins in plugins do
|
||||
for plugin, hostClass in applicablePlugins do
|
||||
match getGenerateRawFromRaw hostClass with
|
||||
| None -> ()
|
||||
|
Reference in New Issue
Block a user