diff --git a/Dapper.Crud.VSExtension/Dapper.Crud.VSExtension.csproj b/Dapper.Crud.VSExtension/Dapper.Crud.VSExtension.csproj index d5a7b6f..d0ae471 100644 --- a/Dapper.Crud.VSExtension/Dapper.Crud.VSExtension.csproj +++ b/Dapper.Crud.VSExtension/Dapper.Crud.VSExtension.csproj @@ -84,6 +84,12 @@ Always true + + true + + + true + Always true diff --git a/Dapper.Crud.VSExtension/Helpers/AssemblyHelper.cs b/Dapper.Crud.VSExtension/Helpers/AssemblyHelper.cs index 01b79c4..0982777 100644 --- a/Dapper.Crud.VSExtension/Helpers/AssemblyHelper.cs +++ b/Dapper.Crud.VSExtension/Helpers/AssemblyHelper.cs @@ -32,8 +32,8 @@ private static Assembly BuildAssembly(string code) compilerparams.ReferencedAssemblies.Add("System.ComponentModel.DataAnnotations.dll"); compilerparams.ReferencedAssemblies.Add("System.Web.dll"); compilerparams.ReferencedAssemblies.Add("System.Web.Abstractions.dll"); - compilerparams.ReferencedAssemblies.Add("System.Web.Mvc.dll"); - compilerparams.ReferencedAssemblies.Add("System.Web.Optimization.dll"); + // compilerparams.ReferencedAssemblies.Add("System.Web.Mvc.dll"); + // compilerparams.ReferencedAssemblies.Add("System.Web.Optimization.dll"); CompilerResults results = compiler.CompileAssemblyFromSource(compilerparams, code); diff --git a/Dapper.Crud.VSExtension/Helpers/ClassGenerator.cs b/Dapper.Crud.VSExtension/Helpers/ClassGenerator.cs index 2ccf499..f4d0d77 100644 --- a/Dapper.Crud.VSExtension/Helpers/ClassGenerator.cs +++ b/Dapper.Crud.VSExtension/Helpers/ClassGenerator.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Linq; +using System.Text; namespace Dapper.Crud.VSExtension.Helpers { @@ -6,6 +7,7 @@ public static class ClassGenerator { public static string GenerateClassBody(string model, bool interfaceEnabled) { + model = FixClassName(model); var sb = new StringBuilder(); sb.AppendLine(interfaceEnabled ? $"public class {model}Repository : I{model}Repository" @@ -14,5 +16,15 @@ public static string GenerateClassBody(string model, bool interfaceEnabled) return sb.ToString(); } + + private static string FixClassName(string model) + { + if (model.Contains("\\")) + { + var str = model.Split('\\'); + model = str.Last(); // last item of the array + } + return model; + } } } \ No newline at end of file diff --git a/Dapper.Crud.VSExtension/Helpers/DapperGenerator.cs b/Dapper.Crud.VSExtension/Helpers/DapperGenerator.cs index a472fa7..baef64a 100644 --- a/Dapper.Crud.VSExtension/Helpers/DapperGenerator.cs +++ b/Dapper.Crud.VSExtension/Helpers/DapperGenerator.cs @@ -47,6 +47,7 @@ public static string SelectJoin(List models, List> p public static string Select(string model, IList properties, bool generateMethod, bool generateClass) { + model = FixClassName(model); var space = ""; if (generateMethod) @@ -70,6 +71,16 @@ public static string Select(string model, IList properties, bool g return sb.ToString(); } + private static string FixClassName(string model) + { + if (model.Contains("\\")) + { + var str = model.Split('\\'); + model = str.Last(); // last item of the array + } + return model; + } + public static string Insert(string model, IList properties, bool generateMethod, bool generateClass, bool autoIncrement) { var space = ""; diff --git a/Dapper.Crud.VSExtension/Helpers/InterfaceGenerator.cs b/Dapper.Crud.VSExtension/Helpers/InterfaceGenerator.cs index f6f7289..a82aadb 100644 --- a/Dapper.Crud.VSExtension/Helpers/InterfaceGenerator.cs +++ b/Dapper.Crud.VSExtension/Helpers/InterfaceGenerator.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Linq; +using System.Text; namespace Dapper.Crud.VSExtension.Helpers { @@ -6,6 +7,8 @@ public static class InterfaceGenerator { public static string GenerateInterfaceBody(string model) { + model = FixClassName(model); + var sb = new StringBuilder(); sb.AppendLine(""); sb.AppendLine($"public interface I{model}Repository"); @@ -16,6 +19,8 @@ public static string GenerateInterfaceBody(string model) public static string GenerateSelect(string model) { + model = FixClassName(model); + var sb = new StringBuilder(); sb.AppendLine($" List<{model}> Select{model}();"); @@ -24,6 +29,8 @@ public static string GenerateSelect(string model) public static string GenerateInsert(string model) { + model = FixClassName(model); + var sb = new StringBuilder(); sb.AppendLine($" void Insert{model}({model} {model.ToLower()});"); @@ -32,6 +39,8 @@ public static string GenerateInsert(string model) public static string GenerateUpdate(string model) { + model = FixClassName(model); + var sb = new StringBuilder(); sb.AppendLine($" void Update{model}({model} {model.ToLower()});"); @@ -40,10 +49,22 @@ public static string GenerateUpdate(string model) public static string GenerateDelete(string model) { + model = FixClassName(model); + var sb = new StringBuilder(); sb.AppendLine($" void Delete{model}({model} {model.ToLower()});"); return sb.ToString(); } + + private static string FixClassName(string model) + { + if (model.Contains("\\")) + { + var str = model.Split('\\'); + model = str.Last(); // last item of the array + } + return model; + } } } \ No newline at end of file diff --git a/Dapper.Crud.VSExtension/Helpers/MethodGenerator.cs b/Dapper.Crud.VSExtension/Helpers/MethodGenerator.cs index b45e538..3590ab0 100644 --- a/Dapper.Crud.VSExtension/Helpers/MethodGenerator.cs +++ b/Dapper.Crud.VSExtension/Helpers/MethodGenerator.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Linq; +using System.Text; namespace Dapper.Crud.VSExtension.Helpers { @@ -7,6 +8,7 @@ public static class MethodGenerator public static string GenerateSelect(string content, string model, bool generateClass) { var space = ""; + model = FixClassName(model); if (generateClass) space = " "; @@ -23,6 +25,7 @@ public static string GenerateSelect(string content, string model, bool generateC public static string GenerateInsert(string content, string model, bool generateClass) { var space = ""; + model = FixClassName(model); if (generateClass) space = " "; @@ -39,6 +42,7 @@ public static string GenerateInsert(string content, string model, bool generateC public static string GenerateUpdate(string content, string model, bool generateClass) { var space = ""; + model = FixClassName(model); if (generateClass) space = " "; @@ -55,6 +59,7 @@ public static string GenerateUpdate(string content, string model, bool generateC public static string GenerateDelete(string content, string model, bool generateClass) { var space = ""; + model = FixClassName(model); if (generateClass) space = " "; @@ -67,5 +72,15 @@ public static string GenerateDelete(string content, string model, bool generateC return sb.ToString(); } + + private static string FixClassName(string model) + { + if (model.Contains("\\")) + { + var str = model.Split('\\'); + model = str.Last(); // last item of the array + } + return model; + } } } \ No newline at end of file diff --git a/Dapper.Crud.VSExtension/Properties/AssemblyInfo.cs b/Dapper.Crud.VSExtension/Properties/AssemblyInfo.cs index b91a2c6..894e679 100644 --- a/Dapper.Crud.VSExtension/Properties/AssemblyInfo.cs +++ b/Dapper.Crud.VSExtension/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.3.0.0")] -[assembly: AssemblyFileVersion("2.3.0.0")] +[assembly: AssemblyVersion("2.4.0.0")] +[assembly: AssemblyFileVersion("2.4.0.0")] diff --git a/Dapper.Crud.VSExtension/dll/System.Web.Mvc.dll b/Dapper.Crud.VSExtension/dll/System.Web.Mvc.dll new file mode 100644 index 0000000..e4fb753 Binary files /dev/null and b/Dapper.Crud.VSExtension/dll/System.Web.Mvc.dll differ diff --git a/Dapper.Crud.VSExtension/dll/System.Web.Optimization.dll b/Dapper.Crud.VSExtension/dll/System.Web.Optimization.dll new file mode 100644 index 0000000..393d416 Binary files /dev/null and b/Dapper.Crud.VSExtension/dll/System.Web.Optimization.dll differ diff --git a/Dapper.Crud.VSExtension/source.extension.vsixmanifest b/Dapper.Crud.VSExtension/source.extension.vsixmanifest index e282f31..f654f1c 100644 --- a/Dapper.Crud.VSExtension/source.extension.vsixmanifest +++ b/Dapper.Crud.VSExtension/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Dapper Crud Generator Generate CRUD easily with Dapper from your existing Models https://github.com/thiagoloureiro/Dapper.Crud.Extension