diff --git a/ApplicationTests/ParseMultipleFiles.cs b/ApplicationTests/ParseMultipleFiles.cs
index d980d76..c969258 100644
--- a/ApplicationTests/ParseMultipleFiles.cs
+++ b/ApplicationTests/ParseMultipleFiles.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using CLI;
@@ -9,15 +10,17 @@ namespace ApplicationTests
{
public class ParseMultipleFiles : IDisposable
{
- private readonly ITestOutputHelper output;
+
private readonly string dir = Path.GetFullPath("ParseMultipleFiles", Directory.GetCurrentDirectory());
private readonly Project project;
- public ParseMultipleFiles(ITestOutputHelper output)
+ public ParseMultipleFiles()
{
try
{
Directory.Delete(dir, true);
- } catch (Exception) { }
+ } catch (Exception) {
+ Debug.WriteLine("Delete Directory failed in unit test.");
+ }
Directory.CreateDirectory(dir);
File.WriteAllText(path("First.car"), @"# The first document
@@ -29,12 +32,13 @@ open Person
type School
");
- this.output = output;
project = new Project(dir);
}
[Fact]
+#pragma warning disable IDE0051 // Remove unused private members
private void CreateModule()
+#pragma warning restore IDE0051 // Remove unused private members
{
Assert.Equal(2, project.Modules.Count);
var second = project.FindModule("Second");
diff --git a/ApplicationTests/ProjectFileWatcher.cs b/ApplicationTests/ProjectFileWatcher.cs
index 6546dd1..09944cc 100644
--- a/ApplicationTests/ProjectFileWatcher.cs
+++ b/ApplicationTests/ProjectFileWatcher.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using CLI;
@@ -17,7 +18,9 @@ public ProjectFileWatcher(ITestOutputHelper output)
try
{
Directory.Delete(dir, true);
- } catch (Exception) { }
+ } catch (Exception) {
+ Debug.WriteLine("Delete Directory failed in unit test.");
+ }
this.output = output;
project = new Project(dir);
@@ -30,7 +33,9 @@ public ProjectFileWatcher(ITestOutputHelper output)
}
[Fact]
+#pragma warning disable IDE0051 // Remove unused private members
private void CreateModule()
+#pragma warning restore IDE0051 // Remove unused private members
{
project.CreateModule("Test");
Assert.True(File.Exists(path("Test.car")));
diff --git a/CLI/CLI.csproj b/CLI/CLI.csproj
index 9110d15..a035b38 100644
--- a/CLI/CLI.csproj
+++ b/CLI/CLI.csproj
@@ -17,12 +17,13 @@
+
-
+
diff --git a/CLI/Controllers/ModuleController.cs b/CLI/Controllers/ModuleController.cs
index 2150913..2cf3514 100644
--- a/CLI/Controllers/ModuleController.cs
+++ b/CLI/Controllers/ModuleController.cs
@@ -104,7 +104,7 @@ public async Task SaveModuleTextAsync(string module)
if (m is null)
{
- return await Task.Run(() => NotFound());
+ return await Task.Run(NotFound);
}
else {
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
diff --git a/CLI/Controllers/RouteController.cs b/CLI/Controllers/RouteController.cs
index e50c73a..7bf4d89 100644
--- a/CLI/Controllers/RouteController.cs
+++ b/CLI/Controllers/RouteController.cs
@@ -18,11 +18,11 @@ public MonitorController(IActionDescriptorCollectionProvider provider)
public IActionResult GetRoutes()
{
var rs = _provider.ActionDescriptors.Items;
- var routes = rs.Select(x => new {
- Controller = x.RouteValues["controller"],
- Action = x.RouteValues["action"],
- Url = $"{x.RouteValues["controller"]}/{x.RouteValues["action"]}"
- }).ToList();
+ var routes = rs.Select(x => (
+ Controller: x.RouteValues["controller"],
+ Action: x.RouteValues["action"],
+ Url: $"{x.RouteValues["controller"]}/{x.RouteValues["action"]}"
+ )).ToList();
return Ok(routes);
}
}
diff --git a/CLI/Database.cs b/CLI/Database.cs
index c5fce30..f235462 100644
--- a/CLI/Database.cs
+++ b/CLI/Database.cs
@@ -7,7 +7,7 @@
namespace CLI
{
- public class Database
+ public static class Database
{
private static string path = Path.Combine(Project.Current?.OutPath ?? "", "Lexicon.db");
private static ConnectionString ConnectionString()
diff --git a/CLI/Module.cs b/CLI/Module.cs
index 36f7af7..7174433 100644
--- a/CLI/Module.cs
+++ b/CLI/Module.cs
@@ -5,6 +5,7 @@
using Compiler;
using Compiler.AST;
using Mapper.Application;
+using Configuration;
namespace CLI
{
@@ -20,7 +21,6 @@ public class Module : IDisposable
public ASTGenerator Generator { get; private set; }
public DateTime LastParsed { get; private set; }
-
public Module(string path, string basePath, Project project)
{
this.Path = path;
@@ -45,7 +45,7 @@ public void Parse()
public void SaveModuleOutput(bool decend = true, bool suppressMessage = false)
{
- this.Transpiler.StartTranspilation(this.Name);
+ this.Transpiler.StartTranspilation(this.Name, Project.CarConfig?.ErdConfig ?? new ErdConfig());
if (!suppressMessage)
{
Console.WriteLine($"Perfectly parsed: {Name}");
@@ -114,7 +114,7 @@ private string ReadModuleText()
}
catch (IOException ioe)
{
- Console.WriteLine("ReadModuleText: Caught Exception reading file [{0}]", ioe.ToString());
+ Console.WriteLine("ReadModuleText: Caught Exception reading file [{0}]", ioe);
throw ioe;
}
}
diff --git a/CLI/Project.CarConfig.cs b/CLI/Project.CarConfig.cs
index 1dbcbb5..dc34337 100644
--- a/CLI/Project.CarConfig.cs
+++ b/CLI/Project.CarConfig.cs
@@ -1,4 +1,5 @@
using System;
+using Configuration;
namespace CLI
{
diff --git a/CLI/Project.cs b/CLI/Project.cs
index 85b05ca..6bc88ea 100644
--- a/CLI/Project.cs
+++ b/CLI/Project.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using CLI.Signals;
using Compiler.AST;
+using Configuration;
namespace CLI
{
@@ -103,7 +104,7 @@ Have fun with your module!
}
catch (IOException ioe)
{
- Console.WriteLine("ReadModuleText: Caught Exception reading file [{0}]", ioe.ToString());
+ Console.WriteLine("ReadModuleText: Caught Exception reading file [{0}]", ioe);
throw ioe;
}
}
@@ -249,7 +250,7 @@ public void Dispose()
}
- private class Helpers
+ private static class Helpers
{
public static string ReadAsset(string name)
{
diff --git a/CLI/Transpiler.cs b/CLI/Transpiler.cs
index 62e2121..24e15f7 100644
--- a/CLI/Transpiler.cs
+++ b/CLI/Transpiler.cs
@@ -8,6 +8,7 @@
using Mapper.HTML;
using Mapper.JSON;
using Mapper.XSD;
+using Configuration;
namespace CLI
{
@@ -63,7 +64,7 @@ public Dictionary JsonToString()
}
- public void StartTranspilation(string moduleName = "")
+ public void StartTranspilation(string moduleName, ErdConfig erdConfig)
{
this.Imports = ImportResolver.ResolveImports(this.Generator);
this.Generator.Resolve(this.Imports);
@@ -71,7 +72,7 @@ public void StartTranspilation(string moduleName = "")
this.XsdMapper = new XSDMapper(this.Generator);
this.XsdMapper.Start().ToList();
- this.HtmlMapper = new HtmlMapper(this.Generator);
+ this.HtmlMapper = new HtmlMapper(this.Generator, erdConfig);
this.HtmlMapper.Start().ToList();
this.JsonMapper = new JsonMapper(this.Generator);
diff --git a/CLI/WebServer.cs b/CLI/WebServer.cs
index 3633a55..6a2cef0 100644
--- a/CLI/WebServer.cs
+++ b/CLI/WebServer.cs
@@ -9,7 +9,7 @@
namespace CLI
{
- public class WebServer
+ public static class WebServer
{
public static string RootPath = "";
public static Task Start(string rootPath)
diff --git a/Compiler/AST/ASTData.cs b/Compiler/AST/ASTData.cs
index fd69567..6e8362a 100644
--- a/Compiler/AST/ASTData.cs
+++ b/Compiler/AST/ASTData.cs
@@ -66,7 +66,6 @@ public object Clone()
ObjectCloner.CloneList(this.Annotations.ToList()),
ObjectCloner.CloneList(this.Directives.ToList()),
ObjectCloner.CloneList(this.Options.ToList()));
- { };
}
}
}
diff --git a/Compiler/AST/ASTMarkdown.cs b/Compiler/AST/ASTMarkdown.cs
deleted file mode 100644
index 04bc291..0000000
--- a/Compiler/AST/ASTMarkdown.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-namespace Compiler.AST
-{
- public class ASTMarkdown
- {
- public string Markdown { get; set; } = "";
- public ASTMarkdown() { }
- }
-}
diff --git a/Compiler/AST/ASTTypeField.cs b/Compiler/AST/ASTTypeField.cs
index 6b39d5f..71c00de 100644
--- a/Compiler/AST/ASTTypeField.cs
+++ b/Compiler/AST/ASTTypeField.cs
@@ -168,7 +168,7 @@ public void SetRestriction(string key, string value, ASTRestriction original)
}
public bool Equals([AllowNull] ASTTypeField x, [AllowNull] ASTTypeField y) => x.Name == y.Name;
- public int GetHashCode([DisallowNull] ASTTypeField obj) => ((object)obj).GetHashCode();
+ public int GetHashCode([DisallowNull] ASTTypeField obj) => obj.GetHashCode();
public override string ToString() => $"{Name}: {String.Join(" ", Types)};";
}
diff --git a/Compiler/Lexer.cs b/Compiler/Lexer.cs
index f15c5bd..7f5c7eb 100644
--- a/Compiler/Lexer.cs
+++ b/Compiler/Lexer.cs
@@ -46,7 +46,7 @@ public IEnumerable Lex(string code)
{
context = true;
var token = TokenLexers.Word(input);
- yield return new Token() {
+ yield return new Token {
EndLine = input.Line,
EndColumn = 0,
StartLine = input.Line,
@@ -75,7 +75,7 @@ public IEnumerable Lex(string code)
yield return TokenLexers.TakeUntillEndOfContext(input);
if (context)
{
- yield return new Token() {
+ yield return new Token {
EndLine = input.Line,
EndColumn = 0,
StartLine = input.Line,
@@ -87,7 +87,7 @@ public IEnumerable Lex(string code)
else if (context && Char2.IsNewLine(input.Current) && TokenLexers.EndContext(input, 1))
{
context = false;
- yield return new Token() {
+ yield return new Token {
EndLine = input.Line,
EndColumn = 0,
StartLine = input.Line,
@@ -203,7 +203,7 @@ public IEnumerable Lex(string code)
// we'll want to end the context, jsut for good measure!
if (context)
{
- yield return new Token() {
+ yield return new Token {
EndLine = input.Line,
EndColumn = 0,
StartLine = input.Line,
@@ -213,7 +213,7 @@ public IEnumerable Lex(string code)
context = false;
}
- yield return new Token() {
+ yield return new Token {
EndLine = input.Line,
EndColumn = 0,
StartLine = input.Line,
diff --git a/Compiler/Pipeline.cs b/Compiler/Pipeline.cs
deleted file mode 100644
index 137e419..0000000
--- a/Compiler/Pipeline.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-namespace Compiler
-{
- public class Pipeline : IPipeline
- {
-
- public Pipeline()
- {
- }
-
- public Pipeline AddStep(IPipelineStep pipelineStep)
- {
- return new Pipeline();
- }
- }
-
- public interface IPipelineStep
- {
-
- }
- public interface IPipeline
- {
- Pipeline AddStep(IPipelineStep pipelineStep);
- }
-}
diff --git a/Compiler/Token.cs b/Compiler/Token.cs
index 2594a9b..c4246e4 100644
--- a/Compiler/Token.cs
+++ b/Compiler/Token.cs
@@ -45,7 +45,7 @@ public object Clone()
{
Value = (string)this.Value.Clone(),
// Performing a lookup will ensure copy by value
- TokenType = (TokenType)((int)this.TokenType),
+ TokenType = (TokenType)this.TokenType,
// int's are never copied by reference, no need to clone
StartColumn = this.StartColumn,
diff --git a/Compiler/Tokens/Lexer.GenericParameter.cs b/Compiler/Tokens/Lexer.GenericParameter.cs
index 6bb1095..ea8c13f 100644
--- a/Compiler/Tokens/Lexer.GenericParameter.cs
+++ b/Compiler/Tokens/Lexer.GenericParameter.cs
@@ -17,7 +17,7 @@ public static Token GenericParameter(Input input)
var startColumn = input.Column;
var startLine = input.Line;
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.Append(input.Current);
while (input.HasNext() && Char.IsLetter(input.Next()))
@@ -25,7 +25,7 @@ public static Token GenericParameter(Input input)
builder.Append(input.Current);
}
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.Identifier.cs b/Compiler/Tokens/Lexer.Identifier.cs
index 406b728..2b835d2 100644
--- a/Compiler/Tokens/Lexer.Identifier.cs
+++ b/Compiler/Tokens/Lexer.Identifier.cs
@@ -16,13 +16,13 @@ public static Token Identifier(Input input)
var startColumn = input.Column;
var startLine = input.Line;
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
while (input.HasNext() && (char.IsLetter(input.Current) || char.IsNumber(input.Current)))
{
builder.Append(input.Current);
input.Next();
}
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
@@ -46,13 +46,13 @@ public static Token QualifiedIdentifier(Input input)
var startColumn = input.Column;
var startLine = input.Line;
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
while (input.HasNext() && (char.IsLetter(input.Current) || char.IsNumber(input.Current) || input.Current == '.'))
{
builder.Append(input.Current);
input.Next();
}
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.Indent.cs b/Compiler/Tokens/Lexer.Indent.cs
index a6b7675..1fc41aa 100644
--- a/Compiler/Tokens/Lexer.Indent.cs
+++ b/Compiler/Tokens/Lexer.Indent.cs
@@ -7,7 +7,7 @@ internal static Token TakeIndent(Input input)
{
input.Next();
- return new Token()
+ return new Token
{
StartIndex = input.Position - 1,
StartColumn = input.Column - 1,
diff --git a/Compiler/Tokens/Lexer.NewLine.cs b/Compiler/Tokens/Lexer.NewLine.cs
index 07d23cb..d41e8b2 100644
--- a/Compiler/Tokens/Lexer.NewLine.cs
+++ b/Compiler/Tokens/Lexer.NewLine.cs
@@ -5,7 +5,7 @@ public static partial class TokenLexers
{
internal static Token TakeNewLine(Input input)
{
- var result = new Token()
+ var result = new Token
{
StartIndex = input.Position,
StartColumn = input.Column,
diff --git a/Compiler/Tokens/Lexer.Number.cs b/Compiler/Tokens/Lexer.Number.cs
index 8c9f9ed..b22aea7 100644
--- a/Compiler/Tokens/Lexer.Number.cs
+++ b/Compiler/Tokens/Lexer.Number.cs
@@ -19,7 +19,7 @@ public static Token Number(Input input)
var startColumn = input.Column;
var startLine = input.Line;
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
while (input.HasNext())
{
if (char.IsNumber(input.Current))
@@ -36,7 +36,7 @@ public static Token Number(Input input)
}
input.Next();
}
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.Operators.cs b/Compiler/Tokens/Lexer.Operators.cs
index a659f4b..f37b591 100644
--- a/Compiler/Tokens/Lexer.Operators.cs
+++ b/Compiler/Tokens/Lexer.Operators.cs
@@ -27,7 +27,7 @@ public static Token Operators(Input input, string source)
input.Next();
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.TakeUntill.cs b/Compiler/Tokens/Lexer.TakeUntill.cs
index 7b69f89..6d0cc4e 100644
--- a/Compiler/Tokens/Lexer.TakeUntill.cs
+++ b/Compiler/Tokens/Lexer.TakeUntill.cs
@@ -20,7 +20,7 @@ internal static Token TakeUntill(Input input, char end, TokenType type)
builder.Append(input.Current);
if (input.HasNext()) input.Next();
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.TakeUntillEndOfContext.cs b/Compiler/Tokens/Lexer.TakeUntillEndOfContext.cs
index 3135aa4..2fc79e2 100644
--- a/Compiler/Tokens/Lexer.TakeUntillEndOfContext.cs
+++ b/Compiler/Tokens/Lexer.TakeUntillEndOfContext.cs
@@ -17,7 +17,7 @@ public static Token TakeUntillEndOfContext(Input input)
builder.Append(input.Current);
input.Next();
}
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.Tokeniser.cs b/Compiler/Tokens/Lexer.Tokeniser.cs
index 86af33d..a4764f7 100644
--- a/Compiler/Tokens/Lexer.Tokeniser.cs
+++ b/Compiler/Tokens/Lexer.Tokeniser.cs
@@ -23,7 +23,7 @@ public static Token TakeLine(Input input, TokenType type = TokenType.Other)
{
builder.Append(input.Current);
}
- var result = new Token()
+ var result = new Token
{
StartIndex = start,
StartColumn = startColumn,
@@ -40,7 +40,7 @@ public static Token TakeLine(Input input, TokenType type = TokenType.Other)
internal static Token Take(Input input, TokenType type)
{
- var result = new Token()
+ var result = new Token
{
StartIndex = input.Position,
StartColumn = input.Column,
diff --git a/Compiler/Tokens/Lexer.Whitespace.cs b/Compiler/Tokens/Lexer.Whitespace.cs
index 278e635..880aa78 100644
--- a/Compiler/Tokens/Lexer.Whitespace.cs
+++ b/Compiler/Tokens/Lexer.Whitespace.cs
@@ -16,7 +16,7 @@ public static Token Whitespace(Input input)
input.Next();
}
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/Tokens/Lexer.Word.cs b/Compiler/Tokens/Lexer.Word.cs
index a83eb54..5f0eb59 100644
--- a/Compiler/Tokens/Lexer.Word.cs
+++ b/Compiler/Tokens/Lexer.Word.cs
@@ -36,7 +36,7 @@ public static Token Word(Input input)
if (word == "compose") type = TokenType.KW_Compose;
if (word == "loop") type = TokenType.KW_Loop;
- return new Token()
+ return new Token
{
StartIndex = start,
StartColumn = startColumn,
diff --git a/Compiler/VisitorBase.cs b/Compiler/VisitorBase.cs
index a2e158a..327a778 100644
--- a/Compiler/VisitorBase.cs
+++ b/Compiler/VisitorBase.cs
@@ -21,7 +21,11 @@ public IEnumerable Start()
foreach (IASTNode node in NodeTree)
{
var result = Visit(node);
+ // is JITed away and replaced by false in case of a non nullable type.
+ // https://stackoverflow.com/questions/5340817/what-should-i-do-about-possible-compare-of-value-type-with-null
+#pragma warning disable RECS0017 // Possible compare of value type with 'null'
if (result != null)
+#pragma warning restore RECS0017 // Possible compare of value type with 'null'
{
yield return result;
}
diff --git a/Compiler/VisitorSource.cs b/Compiler/VisitorSource.cs
index 71736e6..aaeed75 100644
--- a/Compiler/VisitorSource.cs
+++ b/Compiler/VisitorSource.cs
@@ -8,7 +8,7 @@ namespace Compiler
public class VisitorSource
: VisitorBase
{
- List value = new List();
+
public VisitorSource(ASTGenerator generator) : base(generator)
{
@@ -22,7 +22,7 @@ public override string VisitASTAlias(ASTAlias astAlias)
var typeDef = string.Join(" ", astAlias.Types.Select(Visit));
- if (astAlias.Restrictions.Count() == 0)
+ if (!astAlias.Restrictions.Any())
{
parts.Add($@"alias {astAlias.Name} = {typeDef};");
} else
@@ -82,7 +82,7 @@ public override string VisitASTRestriction(ASTRestriction astRestriction)
.Select(a => indent + a);
var a = String.Join(Environment.NewLine, annotations);
- if (annotations.Count() > 0)
+ if (annotations.Any())
{
return $"\n{a}\n{indent}& {astRestriction.Key} {astRestriction.Value}";
}
@@ -98,7 +98,7 @@ public override string VisitASTType(ASTType astType)
parts.AddRange(astType.Annotations.Select(Visit));
parts.AddRange(astType.Directives.Select(Visit));
- if (astType.Fields.Count() == 0)
+ if (!astType.Fields.Any())
{
parts.Add($"type {astType.Name}");
}
@@ -121,7 +121,7 @@ public override string VisitASTTypeField(ASTTypeField astTypeField)
var typeDef = string.Join(" ", astTypeField.Types.Select(Visit));
var restrictions = String.Join(Environment.NewLine, astTypeField.Restrictions.Select(Visit));
- if (astTypeField.Restrictions.Count() > 0)
+ if (astTypeField.Restrictions.Any())
{
return $" {astTypeField.Name}: {typeDef}\n{restrictions}\n ;";
} else
diff --git a/CompilerTests/HTML/HtmlTests.cs b/CompilerTests/HTML/HtmlTests.cs
index 10d7ad3..5e321db 100644
--- a/CompilerTests/HTML/HtmlTests.cs
+++ b/CompilerTests/HTML/HtmlTests.cs
@@ -51,7 +51,7 @@ @ The First Name of the Person
_ = mapper.Start().ToList();
var document = mapper.ToString();
- Assert.True(document.Count() > 0);
+ Assert.True(document.Any());
}
[Fact]
@@ -72,7 +72,7 @@ public void TestList()
var document = mapper.ToString();
- Assert.True(document.Count() > 0);
+ Assert.True(document.Any());
}
}
diff --git a/CompilerTests/InputTests.cs b/CompilerTests/InputTests.cs
index 5642800..4d19119 100644
--- a/CompilerTests/InputTests.cs
+++ b/CompilerTests/InputTests.cs
@@ -9,12 +9,7 @@ namespace CompilerTests
public class InputTests
{
- private readonly ITestOutputHelper output;
-
- public InputTests(ITestOutputHelper output)
- {
- this.output = output;
- }
+
[Fact]
public void StreamThroughInput()
diff --git a/CompilerTests/ParserTests_Type.cs b/CompilerTests/ParserTests_Type.cs
index a495bdf..f1afb4a 100644
--- a/CompilerTests/ParserTests_Type.cs
+++ b/CompilerTests/ParserTests_Type.cs
@@ -121,7 +121,7 @@ @ Age as a number is weird ofc!
ASTTypeField ageField = fields[2];
Assert.Equal("Age", ageField.Name);
- Assert.Equal(new List() { new ASTTypeDefinition("Number", "") }, ageField.Types);
+ Assert.Equal(new List { new ASTTypeDefinition("Number", "") }, ageField.Types);
Assert.Single(ageField.Annotations);
}
diff --git a/CompilerTests/SourceVisitor/SourceAliasVisitor.cs b/CompilerTests/SourceVisitor/SourceAliasVisitor.cs
index 9c7ef89..75fc23f 100644
--- a/CompilerTests/SourceVisitor/SourceAliasVisitor.cs
+++ b/CompilerTests/SourceVisitor/SourceAliasVisitor.cs
@@ -9,12 +9,7 @@ namespace CompilerTests.SourceVisitor
{
public class SourceAliasVisitor
{
- private readonly ITestOutputHelper output;
-
- public SourceAliasVisitor(ITestOutputHelper output)
- {
- this.output = output;
- }
+
[Fact]
public void TestASTVisitor()
diff --git a/CompilerTests/SourceVisitor/SourceTypeVisitor.cs b/CompilerTests/SourceVisitor/SourceTypeVisitor.cs
index aa935ab..48bd3ae 100644
--- a/CompilerTests/SourceVisitor/SourceTypeVisitor.cs
+++ b/CompilerTests/SourceVisitor/SourceTypeVisitor.cs
@@ -9,12 +9,7 @@ namespace CompilerTests.SourceVisitor
{
public class SourceTypeVisitor
{
- private readonly ITestOutputHelper output;
-
- public SourceTypeVisitor(ITestOutputHelper output)
- {
- this.output = output;
- }
+
[Fact]
public void TestASTVisitor()
{
diff --git a/CompilerTests/XSD/XSDTests.cs b/CompilerTests/XSD/XSDTests.cs
index ed00af5..1edde06 100644
--- a/CompilerTests/XSD/XSDTests.cs
+++ b/CompilerTests/XSD/XSDTests.cs
@@ -11,12 +11,7 @@ namespace CompilerTests.XSD
{
public class XSDTests
{
- private readonly ITestOutputHelper output;
-
- public XSDTests(ITestOutputHelper output)
- {
- this.output = output;
- }
+
[Fact]
public void CreateXSD()
{
diff --git a/CLI/CarConfig.cs b/Configuration/CarConfig.cs
similarity index 73%
rename from CLI/CarConfig.cs
rename to Configuration/CarConfig.cs
index 8c07fce..bd6fca4 100644
--- a/CLI/CarConfig.cs
+++ b/Configuration/CarConfig.cs
@@ -3,7 +3,7 @@
using System.IO;
using Newtonsoft.Json;
-namespace CLI
+namespace Configuration
{
public class CarConfig
{
@@ -11,8 +11,10 @@ public class CarConfig
public string PortNumber { get; set; } = "5000";
public string Remote { get; set; } = "";
-
+
public LexiconConfig LexiconConfig { get; set; } = new LexiconConfig();
+ public XsdConfig XsdConfig { get; set; } = new XsdConfig();
+ public ErdConfig ErdConfig { get; set; } = new ErdConfig();
public static CarConfig? Load(string path)
{
@@ -21,8 +23,7 @@ public class CarConfig
{
var json = File.ReadAllText(path);
var serializer = new JsonSerializer();
- var result = (CarConfig)serializer.Deserialize(new JsonTextReader(new StringReader(json)), typeof(CarConfig));
-
+ var result = serializer.Deserialize(new JsonTextReader(new StringReader(json)));
return result;
}
return null;
@@ -47,6 +48,16 @@ public class LexiconConfig
public List Domains { get; set; } = new List();
}
+ public class XsdConfig
+ {
+ public bool Enable { get; set; } = true;
+ }
+
+ public class ErdConfig
+ {
+ public bool ShowExtendedFields { get; set; } = true;
+ }
+
}
\ No newline at end of file
diff --git a/Configuration/Configuration.csproj b/Configuration/Configuration.csproj
new file mode 100644
index 0000000..c4a56f9
--- /dev/null
+++ b/Configuration/Configuration.csproj
@@ -0,0 +1,14 @@
+
+
+
+ netcoreapp3.0
+ enable
+
+
+
+
+
+
+
+
+
diff --git a/Mapper.Application/CSharp/CSharpVisitor.cs b/Mapper.Application/CSharp/CSharpVisitor.cs
index 2c7c42c..833002d 100644
--- a/Mapper.Application/CSharp/CSharpVisitor.cs
+++ b/Mapper.Application/CSharp/CSharpVisitor.cs
@@ -55,7 +55,7 @@ namespace {Namespace} {{
}
}
- public class CSharpHelpers
+ public static class CSharpHelpers
{
public static string ToCSharpKeyword ((string, string) types)
{
diff --git a/Mapper.HTML/HTMLMapper.cs b/Mapper.HTML/HTMLMapper.cs
index dd812e0..841613f 100644
--- a/Mapper.HTML/HTMLMapper.cs
+++ b/Mapper.HTML/HTMLMapper.cs
@@ -4,6 +4,7 @@
using Compiler;
using Compiler.AST;
using Markdig;
+using Configuration;
namespace Mapper.HTML
{
@@ -13,6 +14,7 @@ public class HtmlMapper : VisitorDefault
public IEnumerable Errors { get; }
public MermaidMapper MermaidMapper { get; }
public HtmlTableMapper TableMapper { get; }
+ public ErdConfig ErdConfig { get; } = new ErdConfig();
public HtmlMapper(ASTGenerator generator) : base(generator)
{
@@ -21,6 +23,10 @@ public HtmlMapper(ASTGenerator generator) : base(generator)
this.MermaidMapper.Start().ToList();
this.TableMapper = new HtmlTableMapper(generator);
}
+ public HtmlMapper(ASTGenerator generator, ErdConfig erdConfig) : this(generator)
+ {
+ this.ErdConfig = erdConfig;
+ }
public override string VisitASTChapter(ASTChapter astChapter)
{
diff --git a/Mapper.HTML/Mapper.HTML.csproj b/Mapper.HTML/Mapper.HTML.csproj
index ced39cd..01676b7 100644
--- a/Mapper.HTML/Mapper.HTML.csproj
+++ b/Mapper.HTML/Mapper.HTML.csproj
@@ -7,6 +7,7 @@
+
diff --git a/Mapper.JSON/Mapper.JSON.csproj b/Mapper.JSON/Mapper.JSON.csproj
index ac14438..c8f4413 100644
--- a/Mapper.JSON/Mapper.JSON.csproj
+++ b/Mapper.JSON/Mapper.JSON.csproj
@@ -11,6 +11,6 @@
-
+
diff --git a/Mapper.XSD/Mapper.Number.cs b/Mapper.XSD/Mapper.Number.cs
index 80e9458..0eac752 100644
--- a/Mapper.XSD/Mapper.Number.cs
+++ b/Mapper.XSD/Mapper.Number.cs
@@ -35,7 +35,7 @@ public static XmlSchemaType MapDecimal(T e) where T : IElement, INamable, IRe
if (decimals != null)
{
- var mFractionDigits = new XmlSchemaFractionDigitsFacet()
+ var mFractionDigits = new XmlSchemaFractionDigitsFacet
{
Value = decimals is null ? "2" : decimals.Value
};
diff --git a/Mapper.XSD/Mapper.cs b/Mapper.XSD/Mapper.cs
index c990e9b..af979c8 100644
--- a/Mapper.XSD/Mapper.cs
+++ b/Mapper.XSD/Mapper.cs
@@ -4,16 +4,5 @@ namespace Mapper.XSD
public partial class Mapper
{
private const string DefaultSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
-
- private static string ConvertToQualifiedName(string value)
- {
- return value switch
- {
- "String" => "string",
- "Number" => "decimal",
- _ => "string"
- };
- }
-
}
}
diff --git a/Mapper.XSD/XSDMapper.cs b/Mapper.XSD/XSDMapper.cs
index 7df351b..8925a48 100644
--- a/Mapper.XSD/XSDMapper.cs
+++ b/Mapper.XSD/XSDMapper.cs
@@ -44,7 +44,7 @@ public override XmlSchemaObject VisitASTType(ASTType astType)
var description = string.Join(" ", astType.Annotations.Select(a => a.Value));
var schemaAnnotation = new XmlSchemaAnnotation();
- var docs = new XmlSchemaDocumentation()
+ var docs = new XmlSchemaDocumentation
{
Markup = TextToNodeArray(description)
};
@@ -137,7 +137,7 @@ private void ExtractElement(T node) where T : INamable, IRootNode
private XmlNode[] TextToNodeArray(string text)
{
var doc = new XmlDocument();
- return new XmlNode[1] { doc.CreateTextNode(text) };
+ return new XmlNode[] { doc.CreateTextNode(text) };
}
public override XmlSchemaObject? VisitASTData(ASTData astData)
diff --git a/ZDragon.NET.sln b/ZDragon.NET.sln
index ef6ae8f..5f25ef0 100644
--- a/ZDragon.NET.sln
+++ b/ZDragon.NET.sln
@@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mapper.Application", "Mappe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationTests", "ApplicationTests\ApplicationTests.csproj", "{A95E08D8-BFC7-47D9-B36D-23202444E29E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "Configuration\Configuration.csproj", "{091D5B31-A977-44EA-A63A-1D80948F2C9D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +70,10 @@ Global
{A95E08D8-BFC7-47D9-B36D-23202444E29E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A95E08D8-BFC7-47D9-B36D-23202444E29E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A95E08D8-BFC7-47D9-B36D-23202444E29E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {091D5B31-A977-44EA-A63A-1D80948F2C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {091D5B31-A977-44EA-A63A-1D80948F2C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {091D5B31-A977-44EA-A63A-1D80948F2C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {091D5B31-A977-44EA-A63A-1D80948F2C9D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5AFE6847-C9C1-40C5-810C-4C12B4569C11} = {BE20F938-359D-49B2-A33B-4CDF07792C55}