diff --git a/.gitignore b/.gitignore
index 5c520fd3..168d8f85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -150,3 +150,7 @@ $RECYCLE.BIN/
lib/Packages/
src/packages/
/src/.vs/Shaolinq/v15/sqlite3/storage.ide
+
+# Rider IDE
+
+.idea
\ No newline at end of file
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 00000000..c4cf9786
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,32 @@
+version: "3.8"
+
+networks:
+ test-stand:
+
+services:
+ postgress:
+ image: stellirin/postgres-windows:latest
+ environment:
+ - POSTGRES_PASSWORD=postgres
+ ports:
+ - "5432:5432"
+ networks:
+ - test-stand
+ mysql:
+ image: pomelofoundation/mysql-windows:8-ltsc2019
+ ports:
+ - "3306:3306"
+ environment:
+ - MYSQL_ROOT_HOST=%
+ - MYSQL_ROOT_PASSWORD=root
+ networks:
+ - test-stand
+ mssql:
+ image: kkbruce/mssql-server-windows-express:windowsservercore-1809
+ ports:
+ - "1433:1433"
+ environment:
+ - ACCEPT_EULA=Y
+ - sa_password=r00t_p@$$w0rd1
+ networks:
+ - test-stand
diff --git a/lib/.gitignore b/lib/.gitignore
deleted file mode 100644
index e69de29b..00000000
diff --git a/lib/Mono.Data.Sqlite.dll b/lib/Mono.Data.Sqlite.dll
deleted file mode 100644
index fa7c45b1..00000000
Binary files a/lib/Mono.Data.Sqlite.dll and /dev/null differ
diff --git a/nuspec/GeneratedAsync.cs.pp b/nuspec/GeneratedAsync.cs.pp
deleted file mode 100644
index e69de29b..00000000
diff --git a/nuspec/RewriteAsyncAttribute.cs.pp b/nuspec/RewriteAsyncAttribute.cs.pp
deleted file mode 100644
index 3e661d0a..00000000
--- a/nuspec/RewriteAsyncAttribute.cs.pp
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2016 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-using System.Reflection;
-
-namespace $rootnamespace$
-{
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
- internal class RewriteAsyncAttribute
- : Attribute
- {
- public bool ContinueOnCapturedContext { get; set; }
- public MethodAttributes MethodAttributes { get; set; }
- public bool ApplyToDescendents {get; set; }
-
- public RewriteAsyncAttribute()
- : this(default(MethodAttributes))
- {
- }
-
- public RewriteAsyncAttribute(MethodAttributes methodAttributes)
- {
- this.MethodAttributes = methodAttributes;
- }
- }
-}
diff --git a/nuspec/Shaolinq.AsyncRewriter.nuspec b/nuspec/Shaolinq.AsyncRewriter.nuspec
deleted file mode 100644
index 37fb884e..00000000
--- a/nuspec/Shaolinq.AsyncRewriter.nuspec
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- Shaolinq.AsyncRewriter
- $version$
- Shaolinq AsyncRewriter
- Automatically generates async versions of your methods
- true
- Thong Nguyen
- Thong Nguyen
- https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
- https://github.com/tumtumtum/Shaolinq
- false
-
-Stop copying and pasting code in order to support Async/Await! Shaolinq.AsyncRewriter generates async methods from your sync methods using Roslyn.
-AsyncRewriter is used extensively by the Shaolinq ORM/LINQ project.
-
- $releasenotes$
- Copyright (c) 2016-2018 Thong Nguyen (tumtumtum@gmail.com)
- shaolinq async rewriter asyncrewriter await codegen roslyn
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.AsyncRewriter.props b/nuspec/Shaolinq.AsyncRewriter.props
deleted file mode 100644
index 2425f6fe..00000000
--- a/nuspec/Shaolinq.AsyncRewriter.props
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.AsyncRewriter.targets b/nuspec/Shaolinq.AsyncRewriter.targets
deleted file mode 100644
index bc402bc9..00000000
--- a/nuspec/Shaolinq.AsyncRewriter.targets
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
- @(Compile)
- GeneratedAsync.cs
- $(BaseIntermediateOutputPath)\$(Configuration)\GeneratedAsync.cs
-
-
-
- False
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.MySql.nuspec b/nuspec/Shaolinq.MySql.nuspec
deleted file mode 100644
index e6c52611..00000000
--- a/nuspec/Shaolinq.MySql.nuspec
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
- Shaolinq.MySql
- $version$
- Shaolinq ORM and Linq provider for MySql
- A thoughtful ORM and Linq provider for .NET and MySql
- Thong Nguyen
- Thong Nguyen
- https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
- https://github.com/tumtumtum/Shaolinq
- false
- Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
-
-Use this package to add Shaolinq and out-of-the-box MySql support.
-
-Designed to perform super fast and be easy to use, Shaolinq's features also include:
-
-- First class schema-first ORM with WYSIWYG data access and minipulation.
-- First class LINQ support (not the basic kind you see in most other OSS projects).
-- Single trip updating of objects.
-- Support for Sqlite, MySql and Postgres.
-- Automatic database creation and schema migration.
-- Delete LINQ extension for batch server side deletes.
-- Full support for server side date functions (Date.DayOfWeek etc).
-- Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
-- Open Source!
- $releasenotes$
- Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
- shaolinq linq provider orm sqlite mysql sql database
-
-
-
-
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.Postgres.DotConnect.nuspec b/nuspec/Shaolinq.Postgres.DotConnect.nuspec
index 0c77c48a..2c1f9e6f 100644
--- a/nuspec/Shaolinq.Postgres.DotConnect.nuspec
+++ b/nuspec/Shaolinq.Postgres.DotConnect.nuspec
@@ -30,7 +30,7 @@ Designed to perform super fast and be easy to use, Shaolinq's features also incl
shaolinq linq provider orm postgres sql database
-
+
\ No newline at end of file
diff --git a/nuspec/Shaolinq.Postgres.nuspec b/nuspec/Shaolinq.Postgres.nuspec
deleted file mode 100644
index 4a70ade8..00000000
--- a/nuspec/Shaolinq.Postgres.nuspec
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
- Shaolinq.Postgres
- $version$
- Shaolinq ORM and Linq provider for Postgres
- A thoughtful ORM and Linq provider for .NET and Postgres
- Thong Nguyen
- Thong Nguyen
- https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
- https://github.com/tumtumtum/Shaolinq
- false
- Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
-
-Use this package to add Shaolinq and out-of-the-box Postgres support (via Npgsql).
-
-Designed to perform super fast and be easy to use, Shaolinq's features also include:
-
-- First class schema-first ORM with WYSIWYG data access and minipulation.
-- First class LINQ support (not the basic kind you see in most other OSS projects).
-- Single trip updating of objects.
-- Support for Sqlite, MySql and Postgres.
-- Automatic database creation and schema migration.
-- Delete LINQ extension for batch server side deletes.
-- Full support for server side date functions (Date.DayOfWeek etc).
-- Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
-- Open Source!
- $releasenotes$
- Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
- shaolinq linq provider orm postgres sql database
-
-
-
-
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.SqlServer.nuspec b/nuspec/Shaolinq.SqlServer.nuspec
deleted file mode 100644
index 9ebdbacb..00000000
--- a/nuspec/Shaolinq.SqlServer.nuspec
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
- Shaolinq.SqlServer
- $version$
- Shaolinq ORM and Linq provider for SQL Server
- A thoughtful ORM and Linq provider for .NET and SQL Server
- Thong Nguyen
- Thong Nguyen
- https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
- https://github.com/tumtumtum/Shaolinq
- false
- Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
-
-Use this package to add Shaolinq and out-of-the-box MySql support.
-
-Designed to perform super fast and be easy to use, Shaolinq's features also include:
-
-- First class schema-first ORM with WYSIWYG data access and minipulation.
-- First class LINQ support (not the basic kind you see in most other OSS projects).
-- Single trip updating of objects.
-- Support for Sqlite, MySql, Postgres and SQL Server.
-- Automatic database creation and schema migration.
-- Delete LINQ extension for batch server side deletes.
-- Full support for server side date functions (Date.DayOfWeek etc).
-- Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
-- Open Source!
- $releasenotes$
- Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
- shaolinq linq provider orm sqlite mysql sql database
-
-
-
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.Sqlite.nuspec b/nuspec/Shaolinq.Sqlite.nuspec
deleted file mode 100644
index a23a8fa3..00000000
--- a/nuspec/Shaolinq.Sqlite.nuspec
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
- Shaolinq.Sqlite
- $version$
- Shaolinq ORM and Linq provider for Sqlite
- A thoughtful ORM and Linq provider for .NET and Sqlite
- Thong Nguyen
- Thong Nguyen
- https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
- https://github.com/tumtumtum/Shaolinq
- false
- Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
-
-Use this package to add Shaolinq and out-of-the-box Sqlite support.
-
-Designed to perform super fast and be easy to use, Shaolinq's features also include:
-
-- First class schema-first ORM with WYSIWYG data access and minipulation.
-- First class LINQ support (not the basic kind you see in most other OSS projects).
-- Single trip updating of objects.
-- Support for Sqlite, MySql and Postgres.
-- Automatic database creation and schema migration.
-- Delete LINQ extension for batch server side deletes.
-- Full support for server side date functions (Date.DayOfWeek etc).
-- Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
-- Open Source!
- $releasenotes$
- Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
- shaolinq linq provider orm sqlite sql database
-
-
-
-
-
-
\ No newline at end of file
diff --git a/nuspec/Shaolinq.nuspec b/nuspec/Shaolinq.nuspec
deleted file mode 100644
index 3c5c50b4..00000000
--- a/nuspec/Shaolinq.nuspec
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
- Shaolinq
- $version$
- Shaolinq ORM and Linq provider
- A thoughtful ORM and Linq provider for .NET
- Thong Nguyen
- Thong Nguyen
- https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
- https://github.com/tumtumtum/Shaolinq
- false
- Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
-
-Designed to perform super fast and be easy to use, Shaolinq's features also include:
-
-- First class schema-first ORM with WYSIWYG data access and minipulation.
-- First class LINQ support (not the basic kind you see in most other OSS projects).
-- Single trip updating of objects.
-- Support for Sqlite, MySql and Postgres.
-- Automatic database creation and schema migration.
-- Delete LINQ extension for batch server side deletes.
-- Full support for server side date functions (Date.DayOfWeek etc).
-- Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
-- Open Source!
- $releasenotes$
- Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
- shaolinq linq provider orm sqlite mysql postgres sql database
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Shaolinq.AsyncRewriter.Tool/Shaolinq.AsyncRewriter.Tool.csproj b/src/Shaolinq.AsyncRewriter.Tool/Shaolinq.AsyncRewriter.Tool.csproj
index 2bc4df1b..379ac1e6 100644
--- a/src/Shaolinq.AsyncRewriter.Tool/Shaolinq.AsyncRewriter.Tool.csproj
+++ b/src/Shaolinq.AsyncRewriter.Tool/Shaolinq.AsyncRewriter.Tool.csproj
@@ -2,7 +2,7 @@
Exe
- net5.0
+ net6.0
diff --git a/src/Shaolinq.AsyncRewriter/CompilationLookup.cs b/src/Shaolinq.AsyncRewriter/CompilationLookup.cs
index 72c02355..3ddaeb73 100644
--- a/src/Shaolinq.AsyncRewriter/CompilationLookup.cs
+++ b/src/Shaolinq.AsyncRewriter/CompilationLookup.cs
@@ -29,7 +29,7 @@ private bool MethodIsPublicOrAccessibleFromCompilation(IMethodSymbol method)
if ((method.DeclaredAccessibility == Accessibility.Internal
|| method.DeclaredAccessibility == Accessibility.ProtectedOrInternal)
- && Equals(method.ContainingAssembly, this.compilation.Assembly))
+ && SymbolEqualityComparer.Default.Equals(method.ContainingAssembly, this.compilation.Assembly))
{
return true;
}
@@ -61,7 +61,7 @@ public List GetExtensionMethods(string name, ITypeSymbol type)
}
}
- return retval.OrderBy(c => c.Key.ContainingAssembly.Equals(this.compilation.Assembly) ? 0 : c.Value + 1).Select(c => c.Key).ToList();
+ return retval.OrderBy(c => SymbolEqualityComparer.Default.Equals(c.Key.ContainingAssembly,this.compilation.Assembly) ? 0 : c.Value + 1).Select(c => c.Key).ToList();
}
private void Visit(Compilation compilationNode)
diff --git a/src/Shaolinq.AsyncRewriter/GeneratedAsyncMethodSubstitutor.cs b/src/Shaolinq.AsyncRewriter/GeneratedAsyncMethodSubstitutor.cs
index 8959a4fb..a1354e3b 100644
--- a/src/Shaolinq.AsyncRewriter/GeneratedAsyncMethodSubstitutor.cs
+++ b/src/Shaolinq.AsyncRewriter/GeneratedAsyncMethodSubstitutor.cs
@@ -41,7 +41,7 @@ public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax
if (result.Symbol == null)
{
var newNode = node.WithArgumentList(SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(node.ArgumentList.Arguments
- .Where(c => GetArgumentType(c) != this.cancellationTokenSymbol))));
+ .Where(c => !SymbolEqualityComparer.Default.Equals(GetArgumentType(c),this.cancellationTokenSymbol)))));
var visited = Visit(node.Expression);
diff --git a/src/Shaolinq.AsyncRewriter/Generators/AsyncRewriteAttributeClassGenerator.cs b/src/Shaolinq.AsyncRewriter/Generators/AsyncRewriteAttributeClassGenerator.cs
new file mode 100644
index 00000000..db24a3a9
--- /dev/null
+++ b/src/Shaolinq.AsyncRewriter/Generators/AsyncRewriteAttributeClassGenerator.cs
@@ -0,0 +1,40 @@
+using System.Text;
+using Microsoft.CodeAnalysis.Text;
+
+
+namespace Shaolinq.AsyncRewriter.Generators
+{
+ public class AsyncRewriteAttributeClassGenerator
+ {
+ public const string AttributeClassName = "RewriteAsyncAttribute";
+
+ public static SourceText SourceText(string attributeNamespace) => Microsoft.CodeAnalysis.Text.SourceText.From($@"
+// Generated
+using System;
+using System.Reflection;
+
+namespace {attributeNamespace}
+{{
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
+ internal class RewriteAsyncAttribute : Attribute
+ {{
+ public RewriteAsyncAttribute()
+ : this(default(MethodAttributes))
+ {{
+ }}
+
+ public RewriteAsyncAttribute(MethodAttributes methodAttributes)
+ {{
+ this.MethodAttributes = methodAttributes;
+ }}
+
+ public bool ContinueOnCapturedContext {{ get; set; }}
+ public bool ApplyToDescendents {{ get; set; }}
+ public MethodAttributes MethodAttributes {{ get; set; }}
+ }}
+}}
+// End
+", Encoding.UTF8);
+
+ }
+}
\ No newline at end of file
diff --git a/src/Shaolinq.AsyncRewriter/AsyncSourceGenerator.cs b/src/Shaolinq.AsyncRewriter/Generators/AsyncSourceGenerator.cs
similarity index 58%
rename from src/Shaolinq.AsyncRewriter/AsyncSourceGenerator.cs
rename to src/Shaolinq.AsyncRewriter/Generators/AsyncSourceGenerator.cs
index 09d662bd..93ed0ce7 100644
--- a/src/Shaolinq.AsyncRewriter/AsyncSourceGenerator.cs
+++ b/src/Shaolinq.AsyncRewriter/Generators/AsyncSourceGenerator.cs
@@ -1,19 +1,28 @@
using System;
+using System.Diagnostics;
+using System.Linq;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
-namespace Shaolinq.AsyncRewriter
+namespace Shaolinq.AsyncRewriter.Generators
{
[Generator]
public class AsyncSourceGenerator : ISourceGenerator
{
public void Initialize(GeneratorInitializationContext context)
{
+ context.RegisterForPostInitialization(postInitContext =>
+ {
+ var rewriteAsyncAttribute =
+ AsyncRewriteAttributeClassGenerator.SourceText("System");
+
+ postInitContext.AddSource(AsyncRewriteAttributeClassGenerator.AttributeClassName, rewriteAsyncAttribute);
+ });
}
public void Execute(GeneratorExecutionContext context)
{
var r = new Rewriter();
-
try
{
var syntaxTree = r.RewriteAndMerge(context.Compilation.SyntaxTrees, context.Compilation.References);
@@ -22,7 +31,6 @@ public void Execute(GeneratorExecutionContext context)
}
catch (Exception ex)
{
- //Console.WriteLine(ex.ToString());
Console.Error.WriteLine(ex.ToString());
throw;
}
diff --git a/src/Shaolinq.AsyncRewriter/MethodInvocationInspector.cs b/src/Shaolinq.AsyncRewriter/MethodInvocationInspector.cs
index e559bb93..a0498ff5 100644
--- a/src/Shaolinq.AsyncRewriter/MethodInvocationInspector.cs
+++ b/src/Shaolinq.AsyncRewriter/MethodInvocationInspector.cs
@@ -114,7 +114,7 @@ public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax
if (result.Symbol == null)
{
var newNode = node.WithArgumentList(SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(node.ArgumentList.Arguments
- .Where(c => GetArgumentType(c) != this.cancellationTokenSymbol))));
+ .Where(c => !SymbolEqualityComparer.Default.Equals(GetArgumentType(c), this.cancellationTokenSymbol)))));
var visited = Visit(node.Expression);
@@ -270,9 +270,9 @@ public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax
}
}
- if (candidate.ExtensionMethodNormalizingParameters().Any(c => c.Type == this.cancellationTokenSymbol))
+ if (candidate.ExtensionMethodNormalizingParameters().Any(c => SymbolEqualityComparer.Default.Equals(c.Type, this.cancellationTokenSymbol)))
{
- cancellationTokenPos = candidate.ExtensionMethodNormalizingParameters().Count(c => c.Type != this.cancellationTokenSymbol);
+ cancellationTokenPos = candidate.ExtensionMethodNormalizingParameters().Count(c => !SymbolEqualityComparer.Default.Equals(c.Type, this.cancellationTokenSymbol));
}
else
{
diff --git a/src/Shaolinq.AsyncRewriter/Rewriter.cs b/src/Shaolinq.AsyncRewriter/Rewriter.cs
index 4140607a..5fe2d9d9 100644
--- a/src/Shaolinq.AsyncRewriter/Rewriter.cs
+++ b/src/Shaolinq.AsyncRewriter/Rewriter.cs
@@ -320,11 +320,11 @@ private bool AllMethodsInClassShouldBeAsync(ITypeSymbol type)
if (x.Expression.ToString().Equals("false", StringComparison.OrdinalIgnoreCase))
{
- return type == initialType;
+ return SymbolEqualityComparer.Default.Equals(type, initialType);
}
}
- if (attributeSyntax != null && type == initialType)
+ if (attributeSyntax != null && SymbolEqualityComparer.Default.Equals(type, initialType))
{
return true;
}
@@ -494,7 +494,7 @@ private void ValidateAsyncMethod(MethodDeclarationSyntax methodSyntax, SemanticM
{
foreach (var result in results)
{
- if (!result.ReplacementMethodSymbol.Equals(methodSymbol))
+ if (!SymbolEqualityComparer.Default.Equals(result.ReplacementMethodSymbol, methodSymbol))
{
this.log.LogWarning($"Async method call possible in {result.Position.GetLineSpan()}");
this.log.LogWarning($"Replace {result.MethodInvocationSyntax.NormalizeWhitespace()} with {result.ReplacementExpressionSyntax.NormalizeWhitespace()}");
@@ -689,7 +689,7 @@ private MethodDeclarationSyntax RewriteMethodAsync(MethodDeclarationSyntax metho
{
var first = attribute.ConstructorArguments.First();
- if (first.Type.Equals(this.methodAttributesSymbol))
+ if (SymbolEqualityComparer.Default.Equals(first.Type, this.methodAttributesSymbol))
{
var methodAttributes = (MethodAttributes)Enum.ToObject(typeof(MethodAttributes), Convert.ToInt32(first.Value));
diff --git a/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.csproj b/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.csproj
index f93fa4c1..bca02155 100644
--- a/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.csproj
+++ b/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.csproj
@@ -1,14 +1,36 @@
- netstandard2.0
+ netstandard2.0
Shaolinq.AsyncRewriter
Shaolinq.AsyncRewriter
+ false
+
+
+ latestmajor
+
+
+ Shaolinq.AsyncRewriter
+ 2.0.0
+ Shaolinq AsyncRewriter
+ Thong Nguyen
+ https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
+ https://github.com/tumtumtum/Shaolinq
+ false
+
+ Stop copying and pasting code in order to support Async/Await! Shaolinq.AsyncRewriter generates async methods from your sync methods using Roslyn.
+ AsyncRewriter is used extensively by the Shaolinq ORM/LINQ project.
+
+ $releasenotes$
+ Copyright (c) 2016-2022 Thong Nguyen (tumtumtum@gmail.com)
+ shaolinq async rewriter asyncrewriter await codegen roslyn
-
+
+
+
diff --git a/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.target b/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.target
deleted file mode 100644
index 54b7369a..00000000
--- a/src/Shaolinq.AsyncRewriter/Shaolinq.AsyncRewriter.target
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
- "..\Shaolinq.AsyncRewriter\bin\$(Configuration)\net5.0\Shaolinq.AsyncRewriter.exe"
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Shaolinq.AsyncRewriter/TypeSymbolExtensions.cs b/src/Shaolinq.AsyncRewriter/TypeSymbolExtensions.cs
index ed5d1f32..ffc505c0 100644
--- a/src/Shaolinq.AsyncRewriter/TypeSymbolExtensions.cs
+++ b/src/Shaolinq.AsyncRewriter/TypeSymbolExtensions.cs
@@ -37,7 +37,7 @@ public int GetHashCode(ITypeSymbol obj)
internal static bool EqualsToIgnoreGenericParameters(this ITypeSymbol self, ITypeSymbol other)
{
- if (self == other)
+ if (SymbolEqualityComparer.Default.Equals(self, other))
{
return true;
}
@@ -88,7 +88,7 @@ internal static bool EqualsToIgnoreGenericParameters(this ITypeSymbol self, ITyp
public static int? IsAssignableFrom(this ITypeSymbol self, ITypeSymbol other, int? depth)
{
- if (self == other)
+ if (SymbolEqualityComparer.Default.Equals(self, other))
{
return depth;
}
diff --git a/src/Shaolinq.ExpressionWriter.Tool/Program.cs b/src/Shaolinq.ExpressionWriter.Tool/Program.cs
new file mode 100644
index 00000000..a0849ff1
--- /dev/null
+++ b/src/Shaolinq.ExpressionWriter.Tool/Program.cs
@@ -0,0 +1,42 @@
+namespace Shaolinq.ExpressionWriter.Tool;
+
+public class Program
+{
+ public static void Main(string[] args)
+ {
+ string output = null;
+ string writer = null;
+ string[] input = null;
+
+ for (var i = 0; i < args.Length; i++)
+ {
+ var arg = args[i];
+
+ if (arg == "-writer")
+ {
+ writer = args[++i];
+ }
+ else if (arg == "-output")
+ {
+ output = args[++i];
+ }
+ else
+ {
+ input = new string[args.Length - i];
+
+ Array.Copy(args, i, input, 0, args.Length - i);
+
+ break;
+ }
+ }
+
+ if (writer == "comparer")
+ {
+ ExpressionComparerWriter.Write(input, output);
+ }
+ else if (writer == "hasher")
+ {
+ ExpressionHasherWriter.Write(input, output);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shaolinq.ExpressionWriter.Tool/Shaolinq.ExpressionWriter.Tool.csproj b/src/Shaolinq.ExpressionWriter.Tool/Shaolinq.ExpressionWriter.Tool.csproj
new file mode 100644
index 00000000..492e521c
--- /dev/null
+++ b/src/Shaolinq.ExpressionWriter.Tool/Shaolinq.ExpressionWriter.Tool.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/src/Shaolinq.ExpressionWriter/ExpressionComparerWriter.cs b/src/Shaolinq.ExpressionWriter/ExpressionComparerWriter.cs
index 9f03ddc4..3abb4984 100644
--- a/src/Shaolinq.ExpressionWriter/ExpressionComparerWriter.cs
+++ b/src/Shaolinq.ExpressionWriter/ExpressionComparerWriter.cs
@@ -14,13 +14,19 @@ namespace Shaolinq.ExpressionWriter
public class ExpressionComparerWriter
{
private readonly string[] paths;
+ private IEnumerable syntaxTrees;
- private ExpressionComparerWriter(string[] paths)
+ private ExpressionComparerWriter(string[] paths)
{
this.paths = paths;
}
-
- private IEnumerable GetProperties(INamedTypeSymbol type,bool inherited = true)
+
+ public ExpressionComparerWriter(IEnumerable syntaxTrees)
+ {
+ this.syntaxTrees = syntaxTrees;
+ }
+
+ private IEnumerable GetProperties(INamedTypeSymbol type,bool inherited = true)
{
return GetProperties(type, new HashSet(), inherited);
}
@@ -213,7 +219,11 @@ private BlockSyntax CreateMethodBody(SemanticModel model, INamedTypeSymbol typeS
private string Write()
{
- var syntaxTrees = this.paths.Select(p => SyntaxFactory.ParseSyntaxTree(File.ReadAllText(p))).ToList();
+ if(syntaxTrees == null)
+ {
+ syntaxTrees = this.paths.Select(p => SyntaxFactory.ParseSyntaxTree(File.ReadAllText(p))).ToList();
+ }
+
var compilation = CSharpCompilation.Create("Temp", syntaxTrees, null, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
.AddReferences
(
@@ -285,6 +295,11 @@ private string Write()
return result.ToString();
}
+ internal static string Write(IEnumerable syntaxTrees)
+ {
+ return new ExpressionComparerWriter(syntaxTrees).Write();
+ }
+
public static string Write(string[] sourcePaths)
{
return new ExpressionComparerWriter(sourcePaths).Write();
diff --git a/src/Shaolinq.ExpressionWriter/ExpressionHasherWriter.cs b/src/Shaolinq.ExpressionWriter/ExpressionHasherWriter.cs
index 96832713..fdeb8d32 100644
--- a/src/Shaolinq.ExpressionWriter/ExpressionHasherWriter.cs
+++ b/src/Shaolinq.ExpressionWriter/ExpressionHasherWriter.cs
@@ -13,18 +13,24 @@ namespace Shaolinq.ExpressionWriter
public class ExpressionHasherWriter
{
private readonly string[] paths;
+ private IEnumerable syntaxTrees;
- private ExpressionHasherWriter(string[] paths)
+ private ExpressionHasherWriter(string[] paths)
{
this.paths = paths;
}
-
- private IEnumerable GetProperties(INamedTypeSymbol type,bool inherited = true)
+
+ public ExpressionHasherWriter(IEnumerable syntaxTrees)
+ {
+ this.syntaxTrees = syntaxTrees;
+ }
+
+ private IEnumerable GetProperties(INamedTypeSymbol type,bool inherited = true)
{
return GetProperties(type, new HashSet(), inherited);
}
- private IEnumerable GetProperties(INamedTypeSymbol type, HashSet alreadyAdded, bool inherited = true)
+ private IEnumerable GetProperties(INamedTypeSymbol type, HashSet alreadyAdded, bool inherited = true)
{
foreach (var member in type.GetMembers())
{
@@ -140,7 +146,11 @@ private BlockSyntax CreateMethodBody(SemanticModel model, INamedTypeSymbol typeS
private string Write()
{
- var syntaxTrees = this.paths.Select(p => SyntaxFactory.ParseSyntaxTree(File.ReadAllText(p))).ToList();
+ if(syntaxTrees == null)
+ {
+ syntaxTrees = this.paths.Select(p => SyntaxFactory.ParseSyntaxTree(File.ReadAllText(p))).ToList();
+ }
+
var compilation = CSharpCompilation.Create("Temp", syntaxTrees, null, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
.AddReferences
(
@@ -218,6 +228,11 @@ private string Write()
return result.ToString();
}
+ internal static string Write(IEnumerable syntaxTrees)
+ {
+ return new ExpressionHasherWriter(syntaxTrees).Write();
+ }
+
public static string Write(string[] sourcePaths)
{
return new ExpressionHasherWriter(sourcePaths).Write();
diff --git a/src/Shaolinq.ExpressionWriter/Generators/ExpressionWriterSourceGenerator.cs b/src/Shaolinq.ExpressionWriter/Generators/ExpressionWriterSourceGenerator.cs
new file mode 100644
index 00000000..23a7145c
--- /dev/null
+++ b/src/Shaolinq.ExpressionWriter/Generators/ExpressionWriterSourceGenerator.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Diagnostics;
+using Microsoft.CodeAnalysis;
+
+namespace Shaolinq.ExpressionWriter.Generators
+{
+ [Generator]
+ public class ExpressionWriterSourceGenerator : ISourceGenerator
+ {
+ public void Initialize(GeneratorInitializationContext context)
+ {
+ }
+
+ public void Execute(GeneratorExecutionContext context)
+ {
+ try
+ {
+ context.AddSource("GeneratedSqlExpressionComparer", ExpressionComparerWriter.Write(context.Compilation.SyntaxTrees));
+ context.AddSource("GeneratedSqlExpressionHasher", ExpressionHasherWriter.Write(context.Compilation.SyntaxTrees));
+ }
+ catch (Exception ex)
+ {
+ Console.Error.WriteLine(ex.ToString());
+ throw;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shaolinq.ExpressionWriter/Program.cs b/src/Shaolinq.ExpressionWriter/Program.cs
deleted file mode 100644
index 0ac59aaa..00000000
--- a/src/Shaolinq.ExpressionWriter/Program.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-
-namespace Shaolinq.ExpressionWriter
-{
- public class Program
- {
- public static void Main(string[] args)
- {
- string output = null;
- string writer = null;
- string[] input = null;
-
- for (var i = 0; i < args.Length; i++)
- {
- var arg = args[i];
-
- if (arg == "-writer")
- {
- writer = args[++i];
- }
- else if (arg == "-output")
- {
- output = args[++i];
- }
- else
- {
- input = new string[args.Length - i];
-
- Array.Copy(args, i, input, 0, args.Length - i);
-
- break;
- }
- }
-
- if (writer == "comparer")
- {
- ExpressionComparerWriter.Write(input, output);
- }
- else if (writer == "hasher")
- {
- ExpressionHasherWriter.Write(input, output);
- }
- }
- }
-}
diff --git a/src/Shaolinq.ExpressionWriter/Shaolinq.ExpressionWriter.csproj b/src/Shaolinq.ExpressionWriter/Shaolinq.ExpressionWriter.csproj
index 6b818f96..51628bb9 100644
--- a/src/Shaolinq.ExpressionWriter/Shaolinq.ExpressionWriter.csproj
+++ b/src/Shaolinq.ExpressionWriter/Shaolinq.ExpressionWriter.csproj
@@ -1,15 +1,25 @@
-
+
- net461;net5.0
- Exe
Shaolinq.ExpressionWriter
Shaolinq.ExpressionWriter
+ netstandard2.0
-
-
+
+
+
+
+
+
+ $(GetTargetPathDependsOn);GetDependencyTargetPaths
+
+
+
+
+
+
diff --git a/src/Shaolinq.MySql/GeneratedAsync.cs b/src/Shaolinq.MySql/GeneratedAsync.cs
deleted file mode 100644
index 33230ef4..00000000
--- a/src/Shaolinq.MySql/GeneratedAsync.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-namespace Shaolinq.MySql
-{
-#pragma warning disable
- using System;
- using System.Data;
- using System.Threading;
- using System.Data.Common;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- using Shaolinq;
- using Shaolinq.MySql;
- using Shaolinq.Persistence;
- using global::MySql.Data.MySqlClient;
-
- public partial class MySqlSqlDatabaseContext
- {
- public override Task OpenConnectionAsync()
- {
- return this.OpenConnectionAsync(CancellationToken.None);
- }
-
- public override async Task OpenConnectionAsync(CancellationToken cancellationToken)
- {
- var retval = (await base.OpenConnectionAsync(cancellationToken).ConfigureAwait(false));
- using (var command = retval.CreateCommand())
- {
- var prefix = this.SqlDialect.GetSyntaxSymbolString(SqlSyntaxSymbol.ParameterPrefix);
- var parameter = command.CreateParameter();
- parameter.DbType = DbType.String;
- parameter.ParameterName = $"{prefix}param";
- parameter.Value = this.SqlMode ?? "STRICT_ALL_TABLES";
- command.CommandText = $"SET SESSION sql_mode = {prefix}param;";
- command.Parameters.Add(parameter);
- await command.ExecuteNonQueryExAsync(this.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- return retval;
- }
- }
-}
-
-namespace Shaolinq.MySql
-{
-#pragma warning disable
- using System;
- // Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
- using System.Data;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq.Expressions;
- using Shaolinq;
- using Shaolinq.MySql;
- using Shaolinq.Persistence;
-
- public partial class MySqlSqlTransactionalCommandsContext
- {
- public override Task CommitAsync()
- {
- return this.CommitAsync(CancellationToken.None);
- }
-
- public override async Task CommitAsync(CancellationToken cancellationToken)
- {
- var queue = (IExpressionQueue)this.TransactionContext?.GetAttribute(MySqlSqlDatabaseContext.CommitCleanupQueueKey);
- if (queue != null)
- {
- Expression current;
- while ((current = queue.Dequeue()) != null)
- {
- var formatter = this.SqlDatabaseContext.SqlQueryFormatterManager.CreateQueryFormatter();
- using (var command = (await this.TransactionContext.GetSqlTransactionalCommandsContextAsync(cancellationToken).ConfigureAwait(false)).CreateCommand())
- {
- var formatResult = formatter.Format(current);
- command.CommandText = formatResult.CommandText;
- FillParameters(command, formatResult);
- await command.ExecuteNonQueryExAsync(this.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
- }
- }
-
- await base.CommitAsync(cancellationToken).ConfigureAwait(false);
- }
- }
-}
-
-namespace Shaolinq.MySql
-{
-#pragma warning disable
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq.Expressions;
- using Shaolinq;
- using Shaolinq.MySql;
- using Shaolinq.Persistence;
-
- public partial class MySqlSqlDatabaseSchemaManager
- {
- protected override Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options)
- {
- return this.CreateDatabaseOnlyAsync(dataDefinitionExpressions, options, CancellationToken.None);
- }
-
- protected override async Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options, CancellationToken cancellationToken)
- {
- var retval = false;
- var factory = this.SqlDatabaseContext.CreateDbProviderFactory();
- var overwrite = options == DatabaseCreationOptions.DeleteExistingDatabase;
- using (var dbConnection = factory.CreateConnection())
- {
- dbConnection.ConnectionString = this.SqlDatabaseContext.ServerConnectionString;
- await dbConnection.OpenAsync(cancellationToken).ConfigureAwait(false);
- using (var command = dbConnection.CreateCommand())
- {
- if (overwrite)
- {
- var drop = false;
- command.CommandText = String.Format("SHOW DATABASES;", this.SqlDatabaseContext.DatabaseName);
- using (var reader = (await command.ExecuteReaderAsync(cancellationToken).ConfigureAwait(false)))
- {
- while ((await reader.ReadAsync(cancellationToken).ConfigureAwait(false)))
- {
- var s = reader.GetString(0);
- if (s.Equals(this.SqlDatabaseContext.DatabaseName) || s.Equals(this.SqlDatabaseContext.DatabaseName.ToLower()))
- {
- drop = true;
- break;
- }
- }
- }
-
- if (drop)
- {
- command.CommandText = $"DROP DATABASE {this.SqlDatabaseContext.DatabaseName}";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- command.CommandText = $"CREATE DATABASE {this.SqlDatabaseContext.DatabaseName}\nDEFAULT CHARACTER SET = utf8\nDEFAULT COLLATE = utf8_general_ci;";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- retval = true;
- }
- else
- {
- try
- {
- command.CommandText = $"CREATE DATABASE {this.SqlDatabaseContext.DatabaseName}\nDEFAULT CHARACTER SET = utf8\nDEFAULT COLLATE = utf8_general_ci;";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- retval = true;
- }
- catch
- {
- retval = false;
- }
- }
- }
- }
-
- return retval;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Shaolinq.MySql/MySqlSqlTransactionalCommandsContext.cs b/src/Shaolinq.MySql/MySqlSqlTransactionalCommandsContext.cs
index 97603503..8f2e09d3 100644
--- a/src/Shaolinq.MySql/MySqlSqlTransactionalCommandsContext.cs
+++ b/src/Shaolinq.MySql/MySqlSqlTransactionalCommandsContext.cs
@@ -1,5 +1,6 @@
// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
+using System;
using System.Data;
using System.Linq.Expressions;
using Shaolinq.Persistence;
diff --git a/src/Shaolinq.MySql/RewriteAsyncAttribute.cs b/src/Shaolinq.MySql/RewriteAsyncAttribute.cs
deleted file mode 100644
index 6d919078..00000000
--- a/src/Shaolinq.MySql/RewriteAsyncAttribute.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-using System.Reflection;
-
-namespace Shaolinq.MySql
-{
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
- internal class RewriteAsyncAttribute
- : Attribute
- {
- public bool ContinueOnCapturedContext { get; }
- public MethodAttributes MethodAttributes { get; }
-
- public RewriteAsyncAttribute(MethodAttributes methodAttributes = default(MethodAttributes), bool continueOnCapturedContext = false)
- {
- this.MethodAttributes = methodAttributes;
- this.ContinueOnCapturedContext = continueOnCapturedContext;
- }
- }
-}
diff --git a/src/Shaolinq.MySql/Shaolinq.MySql.csproj b/src/Shaolinq.MySql/Shaolinq.MySql.csproj
index 0f659eab..c8c75adf 100644
--- a/src/Shaolinq.MySql/Shaolinq.MySql.csproj
+++ b/src/Shaolinq.MySql/Shaolinq.MySql.csproj
@@ -4,14 +4,45 @@
netstandard2.0
Shaolinq.MySql
Shaolinq.MySql
+
+
+ Shaolinq.MySql
+ 2.0.0
+ Shaolinq ORM and Linq provider for MySql
+ Thong Nguyen
+ Thong Nguyen
+ https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
+ https://github.com/tumtumtum/Shaolinq
+ false
+ Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
+
+Use this package to add Shaolinq and out-of-the-box MySql support.
+
+Designed to perform super fast and be easy to use, Shaolinq's features also include:
+
+- First class schema-first ORM with WYSIWYG data access and minipulation.
+- First class LINQ support (not the basic kind you see in most other OSS projects).
+- Single trip updating of objects.
+- Support for Sqlite, MySql and Postgres.
+- Automatic database creation and schema migration.
+- Delete LINQ extension for batch server side deletes.
+- Full support for server side date functions (Date.DayOfWeek etc).
+- Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
+- Open Source!
+
+ $releasenotes$
+ Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
+ shaolinq linq provider orm sqlite mysql sql database
-
+
-
+
+
+
diff --git a/src/Shaolinq.Postgres.DotConnect/GeneratedAsync.cs b/src/Shaolinq.Postgres.DotConnect/GeneratedAsync.cs
deleted file mode 100644
index 5b70c045..00000000
--- a/src/Shaolinq.Postgres.DotConnect/GeneratedAsync.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-namespace Shaolinq.Postgres
-{
-#pragma warning disable
- using System;
- // Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
- using System.Data;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq.Expressions;
- using Shaolinq;
- using Shaolinq.Postgres;
- using Shaolinq.Persistence;
- using Shaolinq.Persistence.Linq;
-
- public partial class PostgresSqlDatabaseSchemaManager
- {
- protected override Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options)
- {
- return this.CreateDatabaseOnlyAsync(dataDefinitionExpressions, options, CancellationToken.None);
- }
-
- protected override async Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options, CancellationToken cancellationToken)
- {
- var retval = false;
- var factory = this.SqlDatabaseContext.CreateDbProviderFactory();
- var databaseName = this.SqlDatabaseContext.DatabaseName;
- var overwrite = options == DatabaseCreationOptions.DeleteExistingDatabase;
- this.SqlDatabaseContext.DropAllConnections();
- using (var dbConnection = factory.CreateConnection())
- {
- dbConnection.ConnectionString = this.SqlDatabaseContext.ServerConnectionString;
- await dbConnection.OpenAsync(cancellationToken).ConfigureAwait(false);
- IDbCommand command;
- if (overwrite)
- {
- var drop = false;
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = "SELECT datname FROM pg_database;";
- using (var reader = (await command.ExecuteReaderExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false)))
- {
- while ((await reader.ReadExAsync(cancellationToken).ConfigureAwait(false)))
- {
- var s = reader.GetString(0);
- if (s.Equals(databaseName))
- {
- drop = true;
- break;
- }
- }
- }
- }
-
- if (drop)
- {
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = $"DROP DATABASE \"{databaseName}\";";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
- }
-
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = $"CREATE DATABASE \"{databaseName}\" WITH ENCODING 'UTF8';";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- retval = true;
- }
- else
- {
- try
- {
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = $"CREATE DATABASE \"{databaseName}\" WITH ENCODING 'UTF8';";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- retval = true;
- }
- catch
- {
- retval = false;
- }
- }
- }
-
- return retval;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Shaolinq.Postgres.DotConnect/Shaolinq.Postgres.DotConnect.csproj b/src/Shaolinq.Postgres.DotConnect/Shaolinq.Postgres.DotConnect.csproj
index 7e536748..b23b2511 100644
--- a/src/Shaolinq.Postgres.DotConnect/Shaolinq.Postgres.DotConnect.csproj
+++ b/src/Shaolinq.Postgres.DotConnect/Shaolinq.Postgres.DotConnect.csproj
@@ -10,7 +10,7 @@
Properties
Shaolinq.Postgres.DotConnect
Shaolinq.Postgres.DotConnect
- v4.5.2
+ v4.8
512
@@ -100,22 +100,40 @@
false
-
- ..\packages\dotConnect.Express.for.PostgreSQL.7.10.1061\lib\Devart.Data.dll
+
+ ..\packages\dotConnect.Express.for.PostgreSQL.7.24.2066\lib\Devart.Data.dll
-
- ..\packages\dotConnect.Express.for.PostgreSQL.7.10.1061\lib\Devart.Data.PostgreSql.dll
+
+ ..\packages\dotConnect.Express.for.PostgreSQL.7.24.2066\lib\Devart.Data.PostgreSql.dll
-
- ..\packages\Platform.NET.1.2.5\lib\net452\Platform.dll
+
+
+ ..\packages\Contrib.Platform.NET.2.0.0\lib\netstandard2.0\Platform.dll
-
- ..\packages\Platform.Xml.Serialization.1.2.5\lib\net452\Platform.Xml.Serialization.dll
+
+ ..\packages\Contrib.Platform.Xml.Serialization.2.0.0\lib\netstandard2.0\Platform.Xml.Serialization.dll
+
+
+ ..\packages\System.Configuration.ConfigurationManager.6.0.0\lib\net461\System.Configuration.ConfigurationManager.dll
+
3.5
+
+
+
+
+ ..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll
+
+
+ ..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll
+
+
+ ..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll
+
+
@@ -150,10 +168,6 @@
PostgresUuidSqlDataType.cs
-
- RewriteAsyncAttribute.cs
-
-
@@ -192,7 +206,9 @@
+
+
+
-
\ No newline at end of file
diff --git a/src/Shaolinq.Postgres.DotConnect/app.config b/src/Shaolinq.Postgres.DotConnect/app.config
index 677cb24d..4dadb009 100644
--- a/src/Shaolinq.Postgres.DotConnect/app.config
+++ b/src/Shaolinq.Postgres.DotConnect/app.config
@@ -1,8 +1,77 @@
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shaolinq.Postgres.DotConnect/packages.config b/src/Shaolinq.Postgres.DotConnect/packages.config
index 859b6eed..47cccc26 100644
--- a/src/Shaolinq.Postgres.DotConnect/packages.config
+++ b/src/Shaolinq.Postgres.DotConnect/packages.config
@@ -1,6 +1,11 @@
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shaolinq.Postgres/GeneratedAsync.cs b/src/Shaolinq.Postgres/GeneratedAsync.cs
deleted file mode 100644
index a0e41188..00000000
--- a/src/Shaolinq.Postgres/GeneratedAsync.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-namespace Shaolinq.Postgres
-{
-#pragma warning disable
- using System;
- // Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
- using System.Data;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq.Expressions;
- using Shaolinq;
- using Shaolinq.Postgres;
- using Shaolinq.Persistence;
- using Shaolinq.Persistence.Linq;
-
- public partial class PostgresSqlDatabaseSchemaManager
- {
- protected override Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options)
- {
- return this.CreateDatabaseOnlyAsync(dataDefinitionExpressions, options, CancellationToken.None);
- }
-
- protected override async Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options, CancellationToken cancellationToken)
- {
- var retval = false;
- var factory = this.SqlDatabaseContext.CreateDbProviderFactory();
- var databaseName = this.SqlDatabaseContext.DatabaseName;
- var overwrite = options == DatabaseCreationOptions.DeleteExistingDatabase;
- this.SqlDatabaseContext.DropAllConnections();
- using (var dbConnection = factory.CreateConnection())
- {
- dbConnection.ConnectionString = this.SqlDatabaseContext.ServerConnectionString;
- await dbConnection.OpenAsync(cancellationToken).ConfigureAwait(false);
- IDbCommand command;
- if (overwrite)
- {
- var drop = false;
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = "SELECT datname FROM pg_database;";
- using (var reader = (await command.ExecuteReaderExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false)))
- {
- while ((await reader.ReadExAsync(cancellationToken).ConfigureAwait(false)))
- {
- var s = reader.GetString(0);
- if (s.Equals(databaseName))
- {
- drop = true;
- break;
- }
- }
- }
- }
-
- if (drop)
- {
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = $"DROP DATABASE \"{databaseName}\";";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
- }
-
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = $"CREATE DATABASE \"{databaseName}\" WITH ENCODING 'UTF8';";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- retval = true;
- }
- else
- {
- try
- {
- using (command = dbConnection.CreateCommand())
- {
- command.CommandText = $"CREATE DATABASE \"{databaseName}\" WITH ENCODING 'UTF8';";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- retval = true;
- }
- catch
- {
- retval = false;
- }
- }
- }
-
- return retval;
- }
- }
-}
-
-namespace Shaolinq.Postgres
-{
-#pragma warning disable
- using System;
- using System.Data;
- using System.Threading;
- using System.Threading.Tasks;
- using Npgsql;
- using Platform;
- using Shaolinq;
- using NpgsqlTypes;
- using Shaolinq.Postgres;
- using Shaolinq.Persistence;
-
- public partial class PostgresSqlTransactionalCommandsContext
- {
- public override Task CommitAsync()
- {
- return this.CommitAsync(CancellationToken.None);
- }
-
- public override async Task CommitAsync(CancellationToken cancellationToken)
- {
- if (this.preparedTransactionName != null)
- {
- using (var command = CreateCommand())
- {
- command.CommandText = $"COMMIT PREPARED '{this.preparedTransactionName}';";
- await command.ExecuteNonQueryExAsync(this.DataAccessModel, cancellationToken).ConfigureAwait(false);
- }
- }
-
- await base.CommitAsync(cancellationToken).ConfigureAwait(false);
- }
-
- public override Task RollbackAsync()
- {
- return this.RollbackAsync(CancellationToken.None);
- }
-
- public override async Task RollbackAsync(CancellationToken cancellationToken)
- {
- if (this.preparedTransactionName != null)
- {
- using (var command = CreateCommand())
- {
- command.CommandText = $"ROLLBACK PREPARED '{this.preparedTransactionName}';";
- await command.ExecuteNonQueryExAsync(this.DataAccessModel, cancellationToken).ConfigureAwait(false);
- }
- }
-
- await base.RollbackAsync(cancellationToken).ConfigureAwait(false);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Shaolinq.Postgres/PostgresSqlDatabaseSchemaManager.cs b/src/Shaolinq.Postgres/PostgresSqlDatabaseSchemaManager.cs
index fcc3e549..0d3c7a6f 100644
--- a/src/Shaolinq.Postgres/PostgresSqlDatabaseSchemaManager.cs
+++ b/src/Shaolinq.Postgres/PostgresSqlDatabaseSchemaManager.cs
@@ -1,5 +1,6 @@
// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
+using System;
using System.Data;
using System.Linq.Expressions;
using Shaolinq.Persistence;
diff --git a/src/Shaolinq.Postgres/RewriteAsyncAttribute.cs b/src/Shaolinq.Postgres/RewriteAsyncAttribute.cs
deleted file mode 100644
index 9e9d48c4..00000000
--- a/src/Shaolinq.Postgres/RewriteAsyncAttribute.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-using System.Reflection;
-
-namespace Shaolinq.Postgres
-{
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
- public class RewriteAsyncAttribute
- : Attribute
- {
- public bool ContinueOnCapturedContext { get; set; }
- public MethodAttributes MethodAttributes { get; set; }
-
- public RewriteAsyncAttribute(MethodAttributes methodAttributes = default(MethodAttributes))
- {
- this.MethodAttributes = methodAttributes;
- }
- }
-}
diff --git a/src/Shaolinq.Postgres/Shaolinq.Postgres.csproj b/src/Shaolinq.Postgres/Shaolinq.Postgres.csproj
index 1d4fea0b..72cd84b7 100644
--- a/src/Shaolinq.Postgres/Shaolinq.Postgres.csproj
+++ b/src/Shaolinq.Postgres/Shaolinq.Postgres.csproj
@@ -4,14 +4,45 @@
netstandard2.0
Shaolinq.Postgres
Shaolinq.Postgres
+
+
+ Shaolinq.Postgres
+ 2.0.0
+ Shaolinq ORM and Linq provider for Postgres
+ Thong Nguyen
+ https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
+ https://github.com/tumtumtum/Shaolinq
+ false
+
+ Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
+
+ Use this package to add Shaolinq and out-of-the-box Postgres support (via Npgsql).
+
+ Designed to perform super fast and be easy to use, Shaolinq's features also include:
+
+ - First class schema-first ORM with WYSIWYG data access and minipulation.
+ - First class LINQ support (not the basic kind you see in most other OSS projects).
+ - Single trip updating of objects.
+ - Support for Sqlite, MySql and Postgres.
+ - Automatic database creation and schema migration.
+ - Delete LINQ extension for batch server side deletes.
+ - Full support for server side date functions (Date.DayOfWeek etc).
+ - Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
+ - Open Source!
+
+ $releasenotes$
+ Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
+ shaolinq linq provider orm postgres sql database
-
+
-
+
+
+
diff --git a/src/Shaolinq.SqlServer/GeneratedAsync.cs b/src/Shaolinq.SqlServer/GeneratedAsync.cs
deleted file mode 100644
index 24f2885a..00000000
--- a/src/Shaolinq.SqlServer/GeneratedAsync.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-namespace Shaolinq.SqlServer
-{
-#pragma warning disable
- using System;
- using System.Threading;
- using System.Data.SqlClient;
- using System.Threading.Tasks;
- using System.Linq.Expressions;
- using Shaolinq;
- using Shaolinq.SqlServer;
- using Shaolinq.Persistence;
-
- public partial class SqlServerSqlDatabaseSchemaManager
- {
- protected override Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options)
- {
- return this.CreateDatabaseOnlyAsync(dataDefinitionExpressions, options, CancellationToken.None);
- }
-
- protected override async Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options, CancellationToken cancellationToken)
- {
- var factory = this.SqlDatabaseContext.CreateDbProviderFactory();
- var deleteDatabaseDropsTablesOnly = ((SqlServerSqlDatabaseContext)this.SqlDatabaseContext).DeleteDatabaseDropsTablesOnly;
- using (var connection = factory.CreateConnection())
- {
- if (connection == null)
- {
- throw new InvalidOperationException($"Unable to create connection from {factory}");
- }
-
- try
- {
- var databaseName = this.SqlDatabaseContext.DatabaseName.Trim();
- var context = (SqlServerSqlDatabaseContext)this.SqlDatabaseContext;
- connection.ConnectionString = deleteDatabaseDropsTablesOnly ? this.SqlDatabaseContext.ConnectionString : this.SqlDatabaseContext.ServerConnectionString;
- await connection.OpenAsync(cancellationToken).ConfigureAwait(false);
- using (var command = (SqlCommand)connection.CreateCommand())
- {
- if (options == DatabaseCreationOptions.DeleteExistingDatabase)
- {
- if (deleteDatabaseDropsTablesOnly)
- {
- command.CommandTimeout = Math.Min((int)(this.SqlDatabaseContext.CommandTimeout?.TotalSeconds ?? SqlDatabaseContextInfo.DefaultCommandTimeout), 300);
- command.CommandText = @"
- WHILE(exists(select 1 from INFORMATION_SCHEMA.TABLE_CONSTRAINTS where CONSTRAINT_TYPE='FOREIGN KEY'))
- BEGIN
- DECLARE @sql nvarchar(2000)
- SELECT TOP 1 @sql=('ALTER TABLE ' + TABLE_SCHEMA + '.[' + TABLE_NAME + '] DROP CONSTRAINT [' + CONSTRAINT_NAME + ']')
- FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'
- EXEC (@sql)
- END
- ";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- command.CommandText = @"
- WHILE(exists(select 1 from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA != 'sys' AND TABLE_TYPE = 'BASE TABLE'))
- BEGIN
- declare @sql nvarchar(2000)
- SELECT TOP 1 @sql=('DROP TABLE ' + TABLE_SCHEMA + '.[' + TABLE_NAME + ']')
- FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA != 'sys' AND TABLE_TYPE = 'BASE TABLE'
- EXEC (@sql)
- END
- ";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- command.CommandText = $"IF NOT EXISTS (SELECT 1 FROM sys.databases WHERE NAME = '{databaseName}') CREATE DATABASE [{databaseName}];";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
- else
- {
- command.CommandText = $"IF EXISTS (SELECT 1 FROM sys.databases WHERE NAME = '{databaseName}') DROP DATABASE [{databaseName}];";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- command.CommandText = $"CREATE DATABASE [{databaseName}];";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
- }
- else
- {
- command.CommandText = $"IF EXISTS (SELECT 1 FROM sys.databases WHERE NAME = '{databaseName}') DROP DATABASE [{databaseName}];";
- command.CommandText = $"CREATE DATABASE [{databaseName}];";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- command.CommandText = $"ALTER DATABASE [{databaseName}] SET ALLOW_SNAPSHOT_ISOLATION {(context.AllowSnapshotIsolation ? "ON" : "OFF")};";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- command.CommandText = $"ALTER DATABASE [{databaseName}] SET READ_COMMITTED_SNAPSHOT {(context.ReadCommittedSnapshot ? "ON" : "OFF")};";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- return true;
- }
- }
- catch (Exception e)
- {
- Logger.Log(Logging.LogLevel.Error, () => "Exception creating database: " + e);
- throw;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Shaolinq.SqlServer/RewriteAsyncAttribute.cs b/src/Shaolinq.SqlServer/RewriteAsyncAttribute.cs
deleted file mode 100644
index 9a0441c1..00000000
--- a/src/Shaolinq.SqlServer/RewriteAsyncAttribute.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-using System.Reflection;
-
-namespace Shaolinq.SqlServer
-{
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
- internal class RewriteAsyncAttribute
- : Attribute
- {
- public bool ContinueOnCapturedContext { get; }
- public MethodAttributes MethodAttributes { get; }
-
- public RewriteAsyncAttribute(MethodAttributes methodAttributes = default(MethodAttributes), bool continueOnCapturedContext = false)
- {
- this.MethodAttributes = methodAttributes;
- this.ContinueOnCapturedContext = continueOnCapturedContext;
- }
- }
-}
diff --git a/src/Shaolinq.SqlServer/Shaolinq.SqlServer.csproj b/src/Shaolinq.SqlServer/Shaolinq.SqlServer.csproj
index 699298ea..422ac8d3 100644
--- a/src/Shaolinq.SqlServer/Shaolinq.SqlServer.csproj
+++ b/src/Shaolinq.SqlServer/Shaolinq.SqlServer.csproj
@@ -4,10 +4,45 @@
netstandard2.0
Shaolinq.SqlServer
Shaolinq.SqlServer
+
+
+ Shaolinq.SqlServer
+ 2.0.0
+ Shaolinq ORM and Linq provider for SQL Server
+ Thong Nguyen
+ https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
+ https://github.com/tumtumtum/Shaolinq
+ false
+
+ Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
+
+ Use this package to add Shaolinq and out-of-the-box MySql support.
+
+ Designed to perform super fast and be easy to use, Shaolinq's features also include:
+
+ - First class schema-first ORM with WYSIWYG data access and minipulation.
+ - First class LINQ support (not the basic kind you see in most other OSS projects).
+ - Single trip updating of objects.
+ - Support for Sqlite, MySql, Postgres and SQL Server.
+ - Automatic database creation and schema migration.
+ - Delete LINQ extension for batch server side deletes.
+ - Full support for server side date functions (Date.DayOfWeek etc).
+ - Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
+ - Open Source!
+
+ $releasenotes$
+ Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
+ shaolinq linq provider orm sqlite mysql sql database
+
+
+
+
+
+
diff --git a/src/Shaolinq.Sqlite/GeneratedAsync.cs b/src/Shaolinq.Sqlite/GeneratedAsync.cs
deleted file mode 100644
index a78ad0ac..00000000
--- a/src/Shaolinq.Sqlite/GeneratedAsync.cs
+++ /dev/null
@@ -1,238 +0,0 @@
-namespace Shaolinq.Sqlite
-{
-#pragma warning disable
- using System;
- using System.IO;
- using System.Data;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Linq.Expressions;
- using Shaolinq;
- using Shaolinq.Sqlite;
- using Shaolinq.Persistence;
-
- public abstract partial class SqliteSqlDatabaseSchemaManager
- {
- protected override Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options)
- {
- return this.CreateDatabaseOnlyAsync(dataDefinitionExpressions, options, CancellationToken.None);
- }
-
- protected override async Task CreateDatabaseOnlyAsync(Expression dataDefinitionExpressions, DatabaseCreationOptions options, CancellationToken cancellationToken)
- {
- var retval = false;
- var sqliteSqlDatabaseContext = (SqliteSqlDatabaseContext)this.SqlDatabaseContext;
- var overwrite = options == DatabaseCreationOptions.DeleteExistingDatabase;
- var path = sqliteSqlDatabaseContext.FileName;
- if (sqliteSqlDatabaseContext.IsInMemoryConnection)
- {
- if (overwrite)
- {
- var connection = (await sqliteSqlDatabaseContext.OpenConnectionAsync(cancellationToken).ConfigureAwait(false));
- if (sqliteSqlDatabaseContext.IsSharedCacheConnection)
- {
- // Keeping a reference around so that the in-memory DB survives
- this.inMemoryConnection = (await sqliteSqlDatabaseContext.OpenConnectionAsync(cancellationToken).ConfigureAwait(false));
- }
-
- using (var command = connection.CreateCommand())
- {
- command.CommandText = @"
- PRAGMA writable_schema = 1;
- delete from sqlite_master where type = 'table';
- PRAGMA writable_schema = 0;
- VACUUM;
- ";
- await command.ExecuteNonQueryExAsync(this.SqlDatabaseContext.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
- }
-
- return true;
- }
-
- if (overwrite)
- {
- try
- {
- File.Delete(path);
- }
- catch (FileNotFoundException)
- {
- }
- catch (DirectoryNotFoundException)
- {
- }
-
- for (var i = 0; i < 2; i++)
- {
- try
- {
- CreateFile(path);
- break;
- }
- catch (FileNotFoundException)
- {
- }
- catch (DirectoryNotFoundException)
- {
- }
-
- var directoryPath = Path.GetDirectoryName(path);
- if (!String.IsNullOrEmpty(directoryPath))
- {
- try
- {
- Directory.CreateDirectory(directoryPath);
- }
- catch
- {
- }
- }
- }
-
- retval = true;
- }
- else
- {
- if (!File.Exists(path))
- {
- for (var i = 0; i < 2; i++)
- {
- try
- {
- CreateFile(path);
- break;
- }
- catch (FileNotFoundException)
- {
- }
- catch (DirectoryNotFoundException)
- {
- }
-
- var directoryPath = Path.GetDirectoryName(path);
- if (!String.IsNullOrEmpty(directoryPath))
- {
- try
- {
- Directory.CreateDirectory(directoryPath);
- }
- catch
- {
- }
- }
- }
-
- retval = true;
- }
- else
- {
- retval = false;
- }
- }
-
- return retval;
- }
- }
-}
-
-namespace Shaolinq.Sqlite
-{
-#pragma warning disable
- using System;
- using System.IO;
- using System.Data;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- using Shaolinq;
- using Shaolinq.Sqlite;
- using Shaolinq.Persistence;
-
- public abstract partial class SqliteSqlDatabaseContext
- {
- public override Task OpenConnectionAsync()
- {
- return this.OpenConnectionAsync(CancellationToken.None);
- }
-
- public override async Task OpenConnectionAsync(CancellationToken cancellationToken)
- {
- var retval = (await PrivateOpenConnectionAsync(cancellationToken).ConfigureAwait(false));
- if (retval == null)
- {
- return null;
- }
-
- using (var command = retval.CreateCommand())
- {
- command.CommandText = "PRAGMA foreign_keys = ON;";
- await command.ExecuteNonQueryExAsync(this.DataAccessModel, cancellationToken, true).ConfigureAwait(false);
- }
-
- return retval;
- }
-
- private Task PrivateOpenConnectionAsync()
- {
- return this.PrivateOpenConnectionAsync(CancellationToken.None);
- }
-
- private async Task PrivateOpenConnectionAsync(CancellationToken cancellationToken)
- {
- if (!this.IsInMemoryConnection)
- {
- return (await base.OpenConnectionAsync(cancellationToken).ConfigureAwait(false));
- }
-
- if (this.IsSharedCacheConnection)
- {
- return (await base.OpenConnectionAsync(cancellationToken).ConfigureAwait(false));
- }
-
- return this.connection ?? (this.connection = new SqlitePersistentDbConnection((await base.OpenConnectionAsync(cancellationToken).ConfigureAwait(false))));
- }
- }
-}
-
-namespace Shaolinq.Sqlite
-{
-#pragma warning disable
- using System;
- using System.Data;
- using System.Linq;
- using System.Threading;
- using System.Data.Common;
- using System.Data.SQLite;
- using System.Threading.Tasks;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using Shaolinq;
- using Shaolinq.Sqlite;
- using Shaolinq.Logging;
- using Shaolinq.Persistence;
-
- public partial class SqliteOfficialSqlDatabaseContext
- {
- public override Task BackupAsync(SqlDatabaseContext sqlDatabaseContext)
- {
- return this.BackupAsync(sqlDatabaseContext, CancellationToken.None);
- }
-
- public override async Task BackupAsync(SqlDatabaseContext sqlDatabaseContext, CancellationToken cancellationToken)
- {
- if (!(sqlDatabaseContext is SqliteOfficialSqlDatabaseContext))
- {
- throw new ArgumentException($"Needs to be a {nameof(SqliteOfficialSqlDatabaseContext)}", nameof(sqlDatabaseContext));
- }
-
- using (var connection = (await OpenConnectionAsync(cancellationToken).ConfigureAwait(false)))
- {
- using (var otherConnection = (await sqlDatabaseContext.OpenConnectionAsync(cancellationToken).ConfigureAwait(false)))
- {
- GetSqliteConnection(connection).BackupDatabase(GetSqliteConnection(otherConnection), "main", "main", -1, null, 1000);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Shaolinq.Sqlite/RewriteAsyncAttribute.cs b/src/Shaolinq.Sqlite/RewriteAsyncAttribute.cs
deleted file mode 100644
index 8511f70b..00000000
--- a/src/Shaolinq.Sqlite/RewriteAsyncAttribute.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-using System.Reflection;
-
-namespace Shaolinq.Sqlite
-{
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
- internal class RewriteAsyncAttribute
- : Attribute
- {
- public bool ContinueOnCapturedContext { get; }
- public MethodAttributes MethodAttributes { get; }
-
- public RewriteAsyncAttribute(MethodAttributes methodAttributes = default(MethodAttributes), bool continueOnCapturedContext = false)
- {
- this.MethodAttributes = methodAttributes;
- this.ContinueOnCapturedContext = continueOnCapturedContext;
- }
- }
-}
diff --git a/src/Shaolinq.Sqlite/Shaolinq.Sqlite.csproj b/src/Shaolinq.Sqlite/Shaolinq.Sqlite.csproj
index 55c76595..42b9b71b 100644
--- a/src/Shaolinq.Sqlite/Shaolinq.Sqlite.csproj
+++ b/src/Shaolinq.Sqlite/Shaolinq.Sqlite.csproj
@@ -1,17 +1,48 @@
-
+
netstandard2.0
Shaolinq.Sqlite
Shaolinq.Sqlite
+
+
+ Shaolinq.Sqlite
+ 2.0.0
+ Shaolinq ORM and Linq provider for Sqlite
+ Thong Nguyen
+ https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
+ https://github.com/tumtumtum/Shaolinq
+ false
+
+ Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
+
+ Use this package to add Shaolinq and out-of-the-box Sqlite support.
+
+ Designed to perform super fast and be easy to use, Shaolinq's features also include:
+
+ - First class schema-first ORM with WYSIWYG data access and minipulation.
+ - First class LINQ support (not the basic kind you see in most other OSS projects).
+ - Single trip updating of objects.
+ - Support for Sqlite, MySql and Postgres.
+ - Automatic database creation and schema migration.
+ - Delete LINQ extension for batch server side deletes.
+ - Full support for server side date functions (Date.DayOfWeek etc).
+ - Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
+ - Open Source!
+
+ $releasenotes$
+ Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
+ shaolinq linq provider orm sqlite sql database
-
+
-
+
+
+
diff --git a/src/Shaolinq.Sqlite/SqliteAutoIncrementPrimaryKeyColumnReducer.cs b/src/Shaolinq.Sqlite/SqliteAutoIncrementPrimaryKeyColumnReducer.cs
index ff6e375f..f012cd33 100644
--- a/src/Shaolinq.Sqlite/SqliteAutoIncrementPrimaryKeyColumnReducer.cs
+++ b/src/Shaolinq.Sqlite/SqliteAutoIncrementPrimaryKeyColumnReducer.cs
@@ -106,9 +106,8 @@ protected override Expression VisitColumnDefinition(SqlColumnDefinitionExpressio
if (autoIncrement)
{
- newConstraints = newConstraints
- .Where(c => !c.NotNull)
- .Prepend(new SqlConstraintExpression(ConstraintType.PrimaryKey));
+ EnumerableUtils.Prepend(newConstraints = newConstraints
+ .Where(c => !c.NotNull), new SqlConstraintExpression(ConstraintType.PrimaryKey));
}
if (ReferenceEquals(newConstraints, columnDefinitionExpression.ConstraintExpressions))
diff --git a/src/Shaolinq.Sqlite/SqliteSqlDialect.cs b/src/Shaolinq.Sqlite/SqliteSqlDialect.cs
index f9bda276..2a86b80f 100644
--- a/src/Shaolinq.Sqlite/SqliteSqlDialect.cs
+++ b/src/Shaolinq.Sqlite/SqliteSqlDialect.cs
@@ -30,7 +30,7 @@ public override string GetSyntaxSymbolString(SqlSyntaxSymbol symbol)
switch (symbol)
{
case SqlSyntaxSymbol.AutoIncrement:
- return "AUTOINCREMENT";
+ return "PRIMARY KEY AUTOINCREMENT";
case SqlSyntaxSymbol.StringQuote:
return "'";
case SqlSyntaxSymbol.StringEscape:
diff --git a/src/Shaolinq.sln b/src/Shaolinq.sln
index 11e2ad4c..96d3c7f5 100644
--- a/src/Shaolinq.sln
+++ b/src/Shaolinq.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30907.101
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32414.318
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq", "Shaolinq\Shaolinq.csproj", "{0C8321D6-4DF6-4B90-AF5A-92537D4A7E54}"
ProjectSection(ProjectDependencies) = postProject
@@ -9,19 +9,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq", "Shaolinq\Shaoli
{318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.Tests", "..\tests\Shaolinq.Tests\Shaolinq.Tests.csproj", "{F5BEB79B-3BCA-46AE-A08E-1B86CDD03616}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.Tests", "..\tests\Shaolinq.Tests\Shaolinq.Tests.csproj", "{F5BEB79B-3BCA-46AE-A08E-1B86CDD03616}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.MySql", "Shaolinq.MySql\Shaolinq.MySql.csproj", "{3020F62F-0078-4202-86EB-DD013294D1F2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.MySql", "Shaolinq.MySql\Shaolinq.MySql.csproj", "{3020F62F-0078-4202-86EB-DD013294D1F2}"
ProjectSection(ProjectDependencies) = postProject
{318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.Postgres", "Shaolinq.Postgres\Shaolinq.Postgres.csproj", "{E79DCCED-1693-4E38-98AC-B988D7429615}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.Postgres", "Shaolinq.Postgres\Shaolinq.Postgres.csproj", "{E79DCCED-1693-4E38-98AC-B988D7429615}"
ProjectSection(ProjectDependencies) = postProject
{318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.Sqlite", "Shaolinq.Sqlite\Shaolinq.Sqlite.csproj", "{5FD0C2B3-F601-452A-8C72-D5962B6A089A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.Sqlite", "Shaolinq.Sqlite\Shaolinq.Sqlite.csproj", "{5FD0C2B3-F601-452A-8C72-D5962B6A089A}"
ProjectSection(ProjectDependencies) = postProject
{318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302}
EndProjectSection
@@ -31,12 +31,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.Postgres.DotConnec
{318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.SqlServer", "Shaolinq.SqlServer\Shaolinq.SqlServer.csproj", "{1074BF68-A350-48A8-9769-43AD73537879}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.SqlServer", "Shaolinq.SqlServer\Shaolinq.SqlServer.csproj", "{1074BF68-A350-48A8-9769-43AD73537879}"
ProjectSection(ProjectDependencies) = postProject
{318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.Tests.OtherDataAccessObjects", "..\tests\Shaolinq.Tests.OtherDataAccessObjects\Shaolinq.Tests.OtherDataAccessObjects.csproj", "{737A2E9A-A1B9-4BC8-94BD-5327134142CB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.Tests.OtherDataAccessObjects", "..\tests\Shaolinq.Tests.OtherDataAccessObjects\Shaolinq.Tests.OtherDataAccessObjects.csproj", "{737A2E9A-A1B9-4BC8-94BD-5327134142CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.ExpressionWriter", "Shaolinq.ExpressionWriter\Shaolinq.ExpressionWriter.csproj", "{BC3ECC35-58F4-45ED-A801-95F2D5C4CDFD}"
EndProject
@@ -46,7 +46,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.AsyncRewriter.Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.ExpressionWriter.Tests", "..\tests\Shaolinq.ExpressionWriter.Tests\Shaolinq.ExpressionWriter.Tests.csproj", "{DA01B743-A340-4B07-9B6A-EE37947BD2CE}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shaolinq.AsyncRewriter.Tool", "Shaolinq.AsyncRewriter.Tool\Shaolinq.AsyncRewriter.Tool.csproj", "{F0CE5F64-52A9-405B-BCD0-ACEB6CF43B41}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.AsyncRewriter.Tool", "Shaolinq.AsyncRewriter.Tool\Shaolinq.AsyncRewriter.Tool.csproj", "{F0CE5F64-52A9-405B-BCD0-ACEB6CF43B41}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AsyncRewriter", "AsyncRewriter", "{BB073B54-12FA-498C-A94A-9D154F4D00EE}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExpressionWriter", "ExpressionWriter", "{C91EDDBA-2D1C-478A-84C8-88A7523B88B8}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.ExpressionWriter.Tool", "Shaolinq.ExpressionWriter.Tool\Shaolinq.ExpressionWriter.Tool.csproj", "{3725382B-D77B-431F-B51B-7FDFB9687F4B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shaolinq.AsyncRewriter.Sandbox", "..\tests\Shaolinq.AsyncRewriter.Sandbox\Shaolinq.AsyncRewriter.Sandbox.csproj", "{3F73A8AD-6F5A-4218-8BC9-CCB241137747}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -106,10 +114,27 @@ Global
{F0CE5F64-52A9-405B-BCD0-ACEB6CF43B41}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0CE5F64-52A9-405B-BCD0-ACEB6CF43B41}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0CE5F64-52A9-405B-BCD0-ACEB6CF43B41}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3725382B-D77B-431F-B51B-7FDFB9687F4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3725382B-D77B-431F-B51B-7FDFB9687F4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3725382B-D77B-431F-B51B-7FDFB9687F4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3725382B-D77B-431F-B51B-7FDFB9687F4B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3F73A8AD-6F5A-4218-8BC9-CCB241137747}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3F73A8AD-6F5A-4218-8BC9-CCB241137747}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3F73A8AD-6F5A-4218-8BC9-CCB241137747}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3F73A8AD-6F5A-4218-8BC9-CCB241137747}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {BC3ECC35-58F4-45ED-A801-95F2D5C4CDFD} = {C91EDDBA-2D1C-478A-84C8-88A7523B88B8}
+ {318F3A69-3F34-4CE4-8ED5-22EFE2F6C302} = {BB073B54-12FA-498C-A94A-9D154F4D00EE}
+ {1F63CC9A-3D25-44A1-919C-9731F8ED11DC} = {BB073B54-12FA-498C-A94A-9D154F4D00EE}
+ {DA01B743-A340-4B07-9B6A-EE37947BD2CE} = {C91EDDBA-2D1C-478A-84C8-88A7523B88B8}
+ {F0CE5F64-52A9-405B-BCD0-ACEB6CF43B41} = {BB073B54-12FA-498C-A94A-9D154F4D00EE}
+ {3725382B-D77B-431F-B51B-7FDFB9687F4B} = {C91EDDBA-2D1C-478A-84C8-88A7523B88B8}
+ {3F73A8AD-6F5A-4218-8BC9-CCB241137747} = {BB073B54-12FA-498C-A94A-9D154F4D00EE}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6F0187C2-422B-42D1-A61E-1A265A4DE8CE}
EndGlobalSection
diff --git a/src/Shaolinq/Persistence/Computed/ComputedExpressionParser.cs b/src/Shaolinq/Persistence/Computed/ComputedExpressionParser.cs
index 9b915410..3306cd9b 100644
--- a/src/Shaolinq/Persistence/Computed/ComputedExpressionParser.cs
+++ b/src/Shaolinq/Persistence/Computed/ComputedExpressionParser.cs
@@ -482,14 +482,7 @@ private bool DoesNamespaceResolve(string fullNamespace)
this.namespaces = new HashSet();
this.referencedTypesByName.Select(c => c.Value.Namespace).ForEach(c => this.namespaces.Add(c));
- try
- {
- AppDomain.CurrentDomain.GetAssemblies().SelectMany(c => c.DefinedTypes).ForEach(c => this.namespaces.Add(c.Namespace));
- }
- catch (Exception e)
- {
- throw;
- }
+ AppDomain.CurrentDomain.GetAssemblies().SelectMany(c => c.DefinedTypes).ForEach(c => this.namespaces.Add(c.Namespace));
}
return this.namespaces.Contains(fullNamespace);
diff --git a/src/Shaolinq/Persistence/DbCommandExtensions.cs b/src/Shaolinq/Persistence/DbCommandExtensions.cs
index b3a4706d..ba6709eb 100644
--- a/src/Shaolinq/Persistence/DbCommandExtensions.cs
+++ b/src/Shaolinq/Persistence/DbCommandExtensions.cs
@@ -1,5 +1,6 @@
// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
+using System;
using System.Data;
using System.Data.Common;
diff --git a/src/Shaolinq/Persistence/Linq/ProjectionBuilder.cs b/src/Shaolinq/Persistence/Linq/ProjectionBuilder.cs
index 41928653..c1cce334 100644
--- a/src/Shaolinq/Persistence/Linq/ProjectionBuilder.cs
+++ b/src/Shaolinq/Persistence/Linq/ProjectionBuilder.cs
@@ -312,7 +312,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
var arguments = (IEnumerable)VisitExpressionList(methodCallExpression.Arguments.Skip(1).ToArray());
this.atRootLevel = savedAtRootLevel;
- retval = Expression.Call(instance, methodCallExpression.Method, arguments.Prepend(firstArg));
+ retval = Expression.Call(instance, methodCallExpression.Method, EnumerableUtils.Prepend(arguments, firstArg));
}
else
{
diff --git a/src/Shaolinq/Persistence/Linq/QueryBinder.cs b/src/Shaolinq/Persistence/Linq/QueryBinder.cs
index d958fdfb..73828083 100644
--- a/src/Shaolinq/Persistence/Linq/QueryBinder.cs
+++ b/src/Shaolinq/Persistence/Linq/QueryBinder.cs
@@ -1093,11 +1093,11 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
case "AddHours":
return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddTimeSpan, Visit(methodCallExpression.Object), new SqlFunctionCallExpression(typeof(TimeSpan), SqlFunction.TimeSpanFromHours, VisitExpressionList(methodCallExpression.Arguments)));
case "AddDays":
- return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddDays, VisitExpressionList(methodCallExpression.Arguments).Prepend(Visit(methodCallExpression.Object)));
+ return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddDays, EnumerableUtils.Prepend(VisitExpressionList(methodCallExpression.Arguments), Visit(methodCallExpression.Object)));
case "AddMonths":
- return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddMonths, VisitExpressionList(methodCallExpression.Arguments).Prepend(Visit(methodCallExpression.Object)));
+ return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddMonths, EnumerableUtils.Prepend(methodCallExpression.Arguments, Visit(methodCallExpression.Object)));
case "AddYears":
- return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddYears, VisitExpressionList(methodCallExpression.Arguments).Prepend(Visit(methodCallExpression.Object)));
+ return new SqlFunctionCallExpression(typeof(DateTime), SqlFunction.DateTimeAddYears, EnumerableUtils.Prepend(methodCallExpression.Arguments, Visit(methodCallExpression.Object)));
}
}
diff --git a/src/Shaolinq/Persistence/MarsDbCommand.cs b/src/Shaolinq/Persistence/MarsDbCommand.cs
index 1b601440..2f827514 100644
--- a/src/Shaolinq/Persistence/MarsDbCommand.cs
+++ b/src/Shaolinq/Persistence/MarsDbCommand.cs
@@ -1,5 +1,6 @@
// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
+using System;
using System.Data;
using System.Data.Common;
diff --git a/src/Shaolinq/Persistence/RewriteAsyncAttribute.cs b/src/Shaolinq/Persistence/RewriteAsyncAttribute.cs
deleted file mode 100644
index d266b14f..00000000
--- a/src/Shaolinq/Persistence/RewriteAsyncAttribute.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2007-2018 Thong Nguyen (tumtumtum@gmail.com)
-
-using System;
-using System.Reflection;
-
-namespace Shaolinq.Persistence
-{
- [AttributeUsage(AttributeTargets.Method)]
- internal class RewriteAsyncAttribute
- : Attribute
- {
- public bool ContinueOnCapturedContext { get; }
- public MethodAttributes MethodAttributes { get; }
-
- public RewriteAsyncAttribute(MethodAttributes methodAttributes = default(MethodAttributes), bool continueOnCapturedContext = false)
- {
- this.MethodAttributes = methodAttributes;
- this.ContinueOnCapturedContext = continueOnCapturedContext;
- }
- }
-}
diff --git a/src/Shaolinq/Shaolinq.csproj b/src/Shaolinq/Shaolinq.csproj
index d7fd3d30..6363743d 100644
--- a/src/Shaolinq/Shaolinq.csproj
+++ b/src/Shaolinq/Shaolinq.csproj
@@ -6,16 +6,34 @@
Shaolinq
TRACE;LIBLOG_PUBLIC
true
-
-
-
-
-
+
+ Shaolinq
+ 2.0.0
+ Shaolinq ORM and Linq provider
+ Thong Nguyen
+ https://raw.github.com/tumtumtum/Shaolinq/master/LICENSE.txt
+ https://github.com/tumtumtum/Shaolinq
+ false
+
+ Shaolinq is a thoughtfully designed ORM and Linq provider for .NET
+
+ Designed to perform super fast and be easy to use, Shaolinq's features also include:
+
+ - First class schema-first ORM with WYSIWYG data access and minipulation.
+ - First class LINQ support (not the basic kind you see in most other OSS projects).
+ - Single trip updating of objects.
+ - Support for Sqlite, MySql and Postgres.
+ - Automatic database creation and schema migration.
+ - Delete LINQ extension for batch server side deletes.
+ - Full support for server side date functions (Date.DayOfWeek etc).
+ - Easily extensible with a simple interface for adding support for other ADO.NET compatible databases.
+ - Open Source!
+
+ $releasenotes$
+ Copyright (c) 2007-2015 Thong Nguyen (tumtumtum@gmail.com)
+ shaolinq linq provider orm sqlite mysql postgres sql database
+
@@ -23,26 +41,14 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
-
- "..\Shaolinq.ExpressionWriter\bin\$(Configuration)\net5.0\Shaolinq.ExpressionWriter.exe"
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/tests/Shaolinq.AsyncRewriter.Sandbox/Class1.cs b/tests/Shaolinq.AsyncRewriter.Sandbox/Class1.cs
new file mode 100644
index 00000000..db32cddb
--- /dev/null
+++ b/tests/Shaolinq.AsyncRewriter.Sandbox/Class1.cs
@@ -0,0 +1,52 @@
+
+using System.Reflection;
+
+namespace Shaolinq.AsyncRewriter.Sandbox
+{
+ public partial class Class1
+ {
+ [RewriteAsync]
+ public void Method() => Console.WriteLine("hello");
+
+ [RewriteAsync(MethodAttributes.Public)]
+ private void PrivateMethod() => Console.WriteLine("private");
+
+ public int Value { get; set; }
+ }
+
+ public class Class2
+ {
+ public async Task Method()
+ {
+ var xx = new Class1();
+ await xx.MethodAsync();
+ }
+ }
+}
+
+
+
+//namespace Shaolinq.AsyncRewriter.Sandbox
+//{
+
+// using System;
+// using System.Reflection;
+
+// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
+// internal class RewriteAsyncAttribute : Attribute
+// {
+// public RewriteAsyncAttribute()
+// : this(default(MethodAttributes))
+// {
+// }
+
+// public RewriteAsyncAttribute(MethodAttributes methodAttributes)
+// {
+// this.MethodAttributes = methodAttributes;
+// }
+
+// public bool ContinueOnCapturedContext { get; set; }
+// public bool ApplyToDescendents { get; set; }
+// public MethodAttributes MethodAttributes { get; set; }
+// }
+//}
\ No newline at end of file
diff --git a/tests/Shaolinq.AsyncRewriter.Sandbox/Shaolinq.AsyncRewriter.Sandbox.csproj b/tests/Shaolinq.AsyncRewriter.Sandbox/Shaolinq.AsyncRewriter.Sandbox.csproj
new file mode 100644
index 00000000..461a8efc
--- /dev/null
+++ b/tests/Shaolinq.AsyncRewriter.Sandbox/Shaolinq.AsyncRewriter.Sandbox.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/tests/Shaolinq.AsyncRewriter.Tests/AsyncRewriterTests.cs b/tests/Shaolinq.AsyncRewriter.Tests/AsyncRewriterTests.cs
index 12463fe5..423d9a93 100644
--- a/tests/Shaolinq.AsyncRewriter.Tests/AsyncRewriterTests.cs
+++ b/tests/Shaolinq.AsyncRewriter.Tests/AsyncRewriterTests.cs
@@ -37,21 +37,22 @@ private static IEnumerable GetTestCases()
yield return GetTestCaseData("Nested async methods", "NestedAsync.cs");
yield return GetTestCaseData("Method resolution test", "MethodResolutionTest.cs");
yield return GetTestCaseData("Generic method call test", "GenericMethods.cs");
+ yield return GetTestCaseData("Private method rewritten as public", "PrivateMethodsWithMethodAttributes.cs");
}
private static TestCaseData GetTestCaseData(string name, params string[] inputFiles)
{
- return new TestCaseData(new object[] {inputFiles}).SetName(name);
+ return new TestCaseData(new object[] { inputFiles }).SetName(name);
}
[TestCaseSource(nameof(GetTestCases))]
public void TestRewrite(params string[] inputFiles)
{
var rewriter = new Rewriter();
- var root = Path.Combine(Path.GetDirectoryName(new Uri(GetType().Assembly.CodeBase).LocalPath), "RewriteTests");
+ var root = Path.Combine(Path.GetDirectoryName(new Uri(GetType().Assembly.Location).LocalPath), "RewriteTests");
+ var files = new List(inputFiles) {"RewriteAsyncAttribute.cs"};
+ var result = rewriter.RewriteAndMerge(files.Select(c => Path.Combine(root, c)).ToArray());
- var result = rewriter.RewriteAndMerge(inputFiles.Select(c => Path.Combine(root, c)).ToArray());
-
Assert.IsFalse(result.Contains(": N}\""));
Console.WriteLine(result);
@@ -61,7 +62,7 @@ public void TestRewrite(params string[] inputFiles)
public void TestRewriteCompile(params string[] inputFiles)
{
var rewriter = new Rewriter();
- var root = Path.Combine(Path.GetDirectoryName(new Uri(GetType().Assembly.CodeBase).LocalPath), "RewriteTests");
+ var root = Path.Combine(Path.GetDirectoryName(new Uri(GetType().Assembly.Location).LocalPath), "RewriteTests");
var files = new List(inputFiles) {"RewriteAsyncAttribute.cs"};
var references = new MetadataReference[]
{
@@ -115,7 +116,7 @@ public void TestRewriteCompile(params string[] inputFiles)
Console.Error.WriteLine(diagnostic);
}
- Assert.Fail();
+ Assert.Fail(compileResult.Diagnostics.First().ToString());
}
var assembly = Assembly.Load(ms.ToArray());
@@ -158,7 +159,6 @@ public void TestRewriteCompile(params string[] inputFiles)
}
}
}
-
}
}
}
diff --git a/tests/Shaolinq.AsyncRewriter.Tests/LambdaTests.cs b/tests/Shaolinq.AsyncRewriter.Tests/LambdaTests.cs
index 73409849..fb5e6808 100644
--- a/tests/Shaolinq.AsyncRewriter.Tests/LambdaTests.cs
+++ b/tests/Shaolinq.AsyncRewriter.Tests/LambdaTests.cs
@@ -18,7 +18,7 @@ public static void Foo()
public static Task FooAsync()
{
- return default(Task);
+ return default;
}
public static void Act(Action action)
@@ -27,7 +27,7 @@ public static void Act(Action action)
public static Task ActAsync(Action action)
{
- return default(Task);
+ return default;
}
[RewriteAsync]
@@ -40,7 +40,7 @@ public void Act1()
public void Test()
{
var rewriter = new Rewriter();
- var root = Path.GetDirectoryName(new Uri(GetType().Assembly.CodeBase).LocalPath);
+ var root = Path.GetDirectoryName(new Uri(GetType().Assembly.Location).LocalPath);
var paths = new List { "LambdaTests.cs" };
var result = rewriter.RewriteAndMerge(paths.Select(c => Path.Combine(root, c)).ToArray());
diff --git a/tests/Shaolinq.AsyncRewriter.Tests/RewriteTests/PrivateMethodsWithMethodAttributes.cs b/tests/Shaolinq.AsyncRewriter.Tests/RewriteTests/PrivateMethodsWithMethodAttributes.cs
new file mode 100644
index 00000000..71a82855
--- /dev/null
+++ b/tests/Shaolinq.AsyncRewriter.Tests/RewriteTests/PrivateMethodsWithMethodAttributes.cs
@@ -0,0 +1,13 @@
+using System.Reflection;
+
+namespace Shaolinq.AsyncRewriter.Tests.RewriteTests
+{
+ public partial class PrivateMethodsWithMethodAttributes
+ {
+ [RewriteAsync(MethodAttributes.Public)]
+ private int MyPrivateMethod(int parameter)
+ {
+ return 10 + parameter;
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/Shaolinq.AsyncRewriter.Tests/Shaolinq.AsyncRewriter.Tests.csproj b/tests/Shaolinq.AsyncRewriter.Tests/Shaolinq.AsyncRewriter.Tests.csproj
index 2f7e5624..6f11a969 100644
--- a/tests/Shaolinq.AsyncRewriter.Tests/Shaolinq.AsyncRewriter.Tests.csproj
+++ b/tests/Shaolinq.AsyncRewriter.Tests/Shaolinq.AsyncRewriter.Tests.csproj
@@ -1,7 +1,7 @@
- net461;net5.0
+ net6.0
false
@@ -10,7 +10,7 @@
-
+
@@ -19,6 +19,7 @@
+
diff --git a/tests/Shaolinq.ExpressionWriter.Tests/Shaolinq.ExpressionWriter.Tests.csproj b/tests/Shaolinq.ExpressionWriter.Tests/Shaolinq.ExpressionWriter.Tests.csproj
index 82225cd7..e433faa9 100644
--- a/tests/Shaolinq.ExpressionWriter.Tests/Shaolinq.ExpressionWriter.Tests.csproj
+++ b/tests/Shaolinq.ExpressionWriter.Tests/Shaolinq.ExpressionWriter.Tests.csproj
@@ -1,8 +1,7 @@
- net461;net5.0
-
+ net6.0
false
diff --git a/tests/Shaolinq.Tests/BaseTests.cs b/tests/Shaolinq.Tests/BaseTests.cs
index 3aef1985..929a2094 100644
--- a/tests/Shaolinq.Tests/BaseTests.cs
+++ b/tests/Shaolinq.Tests/BaseTests.cs
@@ -126,7 +126,7 @@ protected DataAccessModelConfiguration CreatePostgresConfiguration(string databa
{
var retval = PostgresConfiguration.Create(new PostgresSqlDatabaseContextInfo()
{
- DatabaseName = databaseName,
+ DatabaseName = databaseName,
ServerName = "localhost",
UserId = "postgres",
Password = "postgres",
diff --git a/tests/Shaolinq.Tests/FixedDate.cs b/tests/Shaolinq.Tests/FixedDate.cs
index af20fa0b..393f74c5 100644
--- a/tests/Shaolinq.Tests/FixedDate.cs
+++ b/tests/Shaolinq.Tests/FixedDate.cs
@@ -76,12 +76,12 @@ public static implicit operator FixedDate(DateTime value)
public static implicit operator FixedDate?(DateTime value)
{
- return value == null ? null : (FixedDate?)new FixedDate(value);
+ return new FixedDate(value);
}
public static implicit operator FixedDate? (DateTime? value)
{
- return value == null ? null : (FixedDate?)new FixedDate(value.Value);
+ return value == null ? null : new FixedDate(value.Value);
}
}
diff --git a/tests/Shaolinq.Tests/LinqTests.cs b/tests/Shaolinq.Tests/LinqTests.cs
index c071578e..d30d6357 100644
--- a/tests/Shaolinq.Tests/LinqTests.cs
+++ b/tests/Shaolinq.Tests/LinqTests.cs
@@ -3547,7 +3547,9 @@ public void Test_Rollback_DataAccessScope_Inside_TransactionScope()
{
using (var dataAccessScope = DataAccessScope.CreateReadCommitted())
{
+#pragma warning disable CS8073
this.model.Students.SingleOrDefault(c => c.Id == null);
+#pragma warning restore CS8073
}
}
}
diff --git a/tests/Shaolinq.Tests/Shaolinq.Tests.csproj b/tests/Shaolinq.Tests/Shaolinq.Tests.csproj
index 88d0e7c9..3776f2f4 100644
--- a/tests/Shaolinq.Tests/Shaolinq.Tests.csproj
+++ b/tests/Shaolinq.Tests/Shaolinq.Tests.csproj
@@ -1,8 +1,7 @@
- net461;net5.0
-
+ net6.0
false
diff --git a/tests/Shaolinq.Tests/TestModel/Person.cs b/tests/Shaolinq.Tests/TestModel/Person.cs
index 49c82117..2b618abb 100644
--- a/tests/Shaolinq.Tests/TestModel/Person.cs
+++ b/tests/Shaolinq.Tests/TestModel/Person.cs
@@ -13,7 +13,7 @@ public abstract class Person
[DefaultValue(Value = "Anonymous")]
public abstract string Firstname { get; set; }
- [Index(LowercaseIndex = true), PersistedMember, SizeConstraint(MaximumLength = 64)]
+ [Index(Lowercase = true), PersistedMember, SizeConstraint(MaximumLength = 64)]
public abstract string Email { get; set; }
[PersistedMember]