diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a5a607e..3a420a14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [0.7.4]
+### Changed
+- Exceptions are no longer written to the generated files but are instead reported to the command line
+With the advent on in line generation, errors out to the source code can be quite disruptive
+
+
## [0.7.3]
### Added
- Added ProjectPath to the project context so the full name of the project is know by the plugin rather than just its project name
diff --git a/Directory.Build.props b/Directory.Build.props
index 13caa452..67568924 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,7 +5,7 @@
https://github.com/$(gitOwner)
$(gitHome)/$(gitName)
$([System.IO.Path]::GetFullPath("$(MSBuildThisFileDirectory)/bin/nupkg"))
- 0.7.3
+ 0.7.4
$(VersionPrefix)$(VersionSuffix)
net5.0;netstandard2.0
diff --git a/src/Myriad/Program.fs b/src/Myriad/Program.fs
index ad5c7fcc..90789e73 100644
--- a/src/Myriad/Program.fs
+++ b/src/Myriad/Program.fs
@@ -142,62 +142,57 @@ module Main =
if verbose then
printfn $"Executing: %s{genType.FullName}..."
- let result =
+ let result, errors =
try
if instance.ValidInputExtensions |> Seq.contains (Path.GetExtension(inputFile))
then
let context = GeneratorContext.Create(configKey, configHandler, inputFile, projectContext, additionalParams)
- Some (instance.Generate(context))
- else None
+ Some (instance.Generate(context)), None
+ else None, None
with
| exc ->
- // emit the module with exception text
- let info = SynComponentInfo.Create (Ident.CreateLong $"%s{genType.Name}Failure")
- let pattern =
- // intentionally generating invalid identifier name to fail the compilation
- let name = LongIdentWithDots.CreateString "!CompilationError"
- SynPat.CreateLongIdent(name, [])
- let letBinding = SynBinding.Let(pattern = pattern, expr = SynExpr.CreateConstString (exc.ToString()))
- let modulDecl = SynModuleDecl.CreateNestedModule(info, [SynModuleDecl.CreateLet [letBinding]])
- Some (Output.Ast [SynModuleOrNamespace.CreateNamespace(Ident.CreateLong "", isRecursive = true, decls = [modulDecl])])
+ let info = $"%s{genType.Name} Failure"
+ let message = exc.ToString()
+ None, Some ($"%s{info}%s{Environment.NewLine}!CompilationError%s{Environment.NewLine}%s{message}")
if verbose then printfn $"Result: '%A{result}'"
- result
+ result, errors
if verbose then
printfn "Execute generators:"
printfn $"Input Filename:\n:%A{inputFile}"
- let generated =
- generators
- |> List.choose (runGenerator inputFile)
+ let generated = generators |> List.map (runGenerator inputFile)
let formattedCode =
let cfg = { FormatConfig.FormatConfig.Default with StrictMode = true }
- let parseTree =
+ let outputCode =
let filename =
- if inlineGeneration then
- inputFile
- else if outputFile.IsSome then
- outputFile.Value
+ if inlineGeneration then inputFile
+ else if outputFile.IsSome then outputFile.Value
else failwith "Error: No OutputFile was included, and --selfgeneration was not specified."
+
generated
- |> List.map (fun f ->
+ |> List.map (fun (f, errors) ->
+ //if theres an error just fail here
+ match errors with
+ | Some error -> failwithf $"%s{error}"
+ | _ -> ()
+
match f with
- | Output.Ast ast ->
+ | Some(Output.Ast ast) ->
let parseTree = ParsedInput.ImplFile(ParsedImplFileInput.CreateFs(filename, modules = ast))
if verbose then
printfn "Generated Ast:------------------------------------"
printfn $"%A{parseTree}"
printfn "--------------------------------------------------"
CodeFormatter.FormatASTAsync(parseTree, "myriad.fsx", [], None, cfg) |> Async.RunSynchronously
- | Output.Source source -> source )
-
-
+ | Some (Output.Source source) -> source
+ | None -> "")
- parseTree |> String.concat Environment.NewLine
+ outputCode |> String.concat Environment.NewLine
let code = Generation.getHeaderedCode formattedCode
if verbose then
diff --git a/test/Myriad.IntegrationPluginTests/ArbitaryFile.fs b/test/Myriad.IntegrationPluginTests/ArbitaryFile.fs
index 20be571c..4cf2f7b0 100644
--- a/test/Myriad.IntegrationPluginTests/ArbitaryFile.fs
+++ b/test/Myriad.IntegrationPluginTests/ArbitaryFile.fs
@@ -2,6 +2,9 @@
// This code was generated by myriad.
// Changes to this file will be lost when the code is regenerated.
//------------------------------------------------------------------------------
+
+
+
namespace TestExample1
module First =
diff --git a/test/Myriad.IntegrationPluginTests/ArbitaryFile2.fs b/test/Myriad.IntegrationPluginTests/ArbitaryFile2.fs
index 3b48bdfd..bc71ed36 100644
--- a/test/Myriad.IntegrationPluginTests/ArbitaryFile2.fs
+++ b/test/Myriad.IntegrationPluginTests/ArbitaryFile2.fs
@@ -2,6 +2,9 @@
// This code was generated by myriad.
// Changes to this file will be lost when the code is regenerated.
//------------------------------------------------------------------------------
+
+
+
namespace UnknownNamespace
module First =
diff --git a/test/Myriad.IntegrationPluginTests/FieldsLensDus.fs b/test/Myriad.IntegrationPluginTests/FieldsLensDus.fs
index 76e2c729..458ec722 100644
--- a/test/Myriad.IntegrationPluginTests/FieldsLensDus.fs
+++ b/test/Myriad.IntegrationPluginTests/FieldsLensDus.fs
@@ -256,3 +256,4 @@ module Currency =
| Custom _ -> true
| _ -> false
+
diff --git a/test/Myriad.IntegrationPluginTests/InputSelfGenerate.fs b/test/Myriad.IntegrationPluginTests/InputSelfGenerate.fs
index 914615c4..eb4418ce 100644
--- a/test/Myriad.IntegrationPluginTests/InputSelfGenerate.fs
+++ b/test/Myriad.IntegrationPluginTests/InputSelfGenerate.fs
@@ -334,3 +334,4 @@ module Currency =
| Custom _ -> true
| _ -> false
+