Skip to content

Commit

Permalink
V2.4 bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoloureiro committed Oct 27, 2018
1 parent 65a36cf commit 18945f1
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Dapper.Crud.VSExtension/Dapper.Crud.VSExtension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="dll\System.Web.Mvc.dll">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="dll\System.Web.Optimization.dll">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="roslyn\csc.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down
4 changes: 2 additions & 2 deletions Dapper.Crud.VSExtension/Helpers/AssemblyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 13 additions & 1 deletion Dapper.Crud.VSExtension/Helpers/ClassGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Text;
using System.Linq;
using System.Text;

namespace Dapper.Crud.VSExtension.Helpers
{
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"
Expand All @@ -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;
}
}
}
11 changes: 11 additions & 0 deletions Dapper.Crud.VSExtension/Helpers/DapperGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static string SelectJoin(List<string> models, List<IList<PropertyInfo>> p

public static string Select(string model, IList<PropertyInfo> properties, bool generateMethod, bool generateClass)
{
model = FixClassName(model);
var space = "";

if (generateMethod)
Expand All @@ -70,6 +71,16 @@ public static string Select(string model, IList<PropertyInfo> 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<PropertyInfo> properties, bool generateMethod, bool generateClass, bool autoIncrement)
{
var space = "";
Expand Down
23 changes: 22 additions & 1 deletion Dapper.Crud.VSExtension/Helpers/InterfaceGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System.Text;
using System.Linq;
using System.Text;

namespace Dapper.Crud.VSExtension.Helpers
{
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");
Expand All @@ -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}();");

Expand All @@ -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()});");

Expand All @@ -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()});");

Expand All @@ -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;
}
}
}
17 changes: 16 additions & 1 deletion Dapper.Crud.VSExtension/Helpers/MethodGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Linq;
using System.Text;

namespace Dapper.Crud.VSExtension.Helpers
{
Expand All @@ -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 = " ";
Expand All @@ -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 = " ";
Expand All @@ -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 = " ";
Expand All @@ -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 = " ";
Expand All @@ -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;
}
}
}
4 changes: 2 additions & 2 deletions Dapper.Crud.VSExtension/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Binary file added Dapper.Crud.VSExtension/dll/System.Web.Mvc.dll
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Dapper.Crud.VSExtension/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="d7261d0b-5f95-456b-9b6a-b127d9afc8e4" Version="2.3" Language="en-US" Publisher="Thiago Loureiro" />
<Identity Id="d7261d0b-5f95-456b-9b6a-b127d9afc8e4" Version="2.4" Language="en-US" Publisher="Thiago Loureiro" />
<DisplayName>Dapper Crud Generator</DisplayName>
<Description xml:space="preserve">Generate CRUD easily with Dapper from your existing Models</Description>
<MoreInfo>https://github.com/thiagoloureiro/Dapper.Crud.Extension</MoreInfo>
Expand Down

0 comments on commit 18945f1

Please sign in to comment.