Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ralmsdeveloper committed Aug 8, 2018
1 parent 1cefbb7 commit 5790afa
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 44 deletions.
11 changes: 6 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ csharp_style_var_when_type_is_apparent = true : warning

# Expression-Bodied members
csharp_style_expression_bodied_accessors = true : warning
csharp_style_expression_bodied_constructors = true : warning
csharp_style_expression_bodied_indexers = true : warning
csharp_style_expression_bodied_methods = true : warning
csharp_style_expression_bodied_operators = true : warning
csharp_style_expression_bodied_properties = true : warning
# Explicitly disabled due to difference in coding style between source and tests
#csharp_style_expression_bodied_constructors = true : warning
#csharp_style_expression_bodied_methods = true : warning

# Pattern matching
csharp_style_pattern_matching_over_as_with_null_check = true : warning
Expand Down Expand Up @@ -151,12 +152,12 @@ dotnet_naming_rule.interface_naming.severity = warning
dotnet_naming_symbols.interface_symbol.applicable_kinds = interface
dotnet_naming_symbols.interface_symbol.applicable_accessibilities = *

# Classes, Structs, Enums, Properties, Methods, Events
# Classes, Structs, Enums, Properties, Methods, Events, Namespaces
dotnet_naming_rule.class_naming.symbols = class_symbol
dotnet_naming_rule.class_naming.style = pascal_case_style
dotnet_naming_rule.class_naming.severity = warning

dotnet_naming_symbols.class_symbol.applicable_kinds = class, struct, enum, property, method, event
dotnet_naming_symbols.class_symbol.applicable_kinds = class, struct, enum, property, method, event, namespace
dotnet_naming_symbols.class_symbol.applicable_accessibilities = *

# Const fields
Expand All @@ -174,7 +175,7 @@ dotnet_naming_rule.public_field_naming.style = pascal_case_style
dotnet_naming_rule.public_field_naming.severity = warning

dotnet_naming_symbols.public_field_symbol.applicable_kinds = field
dotnet_naming_symbols.public_field_symbol.applicable_accessibilities = public
dotnet_naming_symbols.public_field_symbol.applicable_accessibilities = public, internal, protected

# Other fields
dotnet_naming_rule.other_field_naming.symbols = other_field_symbol
Expand Down
15 changes: 15 additions & 0 deletions EFCore.FirebirdSQL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AEDA8CF6-1035-4556-B8D2-5822B04DA4D4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8017995F-8C52-472B-99AA-38052452DAF7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.FirerbirdSql.ScaffoldTest", "EFCore.FirerbirdSql.ScaffoldTest\EFCore.FirerbirdSql.ScaffoldTest.csproj", "{BCDCB2EA-299B-4B11-BBC9-1A4B9CC7F63F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,10 +33,19 @@ Global
{61B6B2E6-80B0-4916-8EE4-91D059CB204F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61B6B2E6-80B0-4916-8EE4-91D059CB204F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61B6B2E6-80B0-4916-8EE4-91D059CB204F}.Release|Any CPU.Build.0 = Release|Any CPU
{BCDCB2EA-299B-4B11-BBC9-1A4B9CC7F63F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCDCB2EA-299B-4B11-BBC9-1A4B9CC7F63F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCDCB2EA-299B-4B11-BBC9-1A4B9CC7F63F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCDCB2EA-299B-4B11-BBC9-1A4B9CC7F63F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C725AC99-64C8-4CBF-B01F-094D5837BC58} = {AEDA8CF6-1035-4556-B8D2-5822B04DA4D4}
{61B6B2E6-80B0-4916-8EE4-91D059CB204F} = {8017995F-8C52-472B-99AA-38052452DAF7}
{BCDCB2EA-299B-4B11-BBC9-1A4B9CC7F63F} = {8017995F-8C52-472B-99AA-38052452DAF7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CCB461D4-B163-4511-8434-CE0C357FDC74}
EndGlobalSection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT' OR '$(CoreOnly)' == 'True'">netcoreapp2.1</TargetFrameworks>
<TargetFramework>net461</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>EFCore.FirebirdSql.FunctionalTests</AssemblyName>
<HasRuntimeOutput>true</HasRuntimeOutput>
<AssemblyOriginatorKeyFile>../EFCore.FirebirdSql/EntityFramework.FirebirdSQL.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<RestoreAdditionalProjectSources>
https://dotnetfeed.blob.core.windows.net/orchestrated-release-2-1/20180515-07/final/index.json
</RestoreAdditionalProjectSources>
<SignAssembly>true</SignAssembly>
<EnableApiCheck>false</EnableApiCheck>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>7.2</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0-preview1-34529" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.0-preview1-34529" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="2.2.0-preview1-34529" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Specification.Tests" Version="2.2.0-preview1-34529" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0-preview1-34529" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0-preview1-34529" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0-preview1-34866" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.0-preview1-34866" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="2.2.0-preview1-34866" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Specification.Tests" Version="2.2.0-preview1-34866" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0-preview1-34866" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0-preview1-34866" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="System.Transactions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EFCore.FirebirdSql\EFCore.FirebirdSql.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FirebirdSql.Data.FirebirdClient" Version="6.0.0" />
<PackageReference Update="FirebirdSql.Data.FirebirdClient" Version="6.1.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Update="xunit.assert" Version="2.4.0" />
<PackageReference Update="xunit.core" Version="2.4.0" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
30 changes: 18 additions & 12 deletions EFCore.FirebirdSql.FunctionalTests/ScaffoldingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore;
using Xunit;
Expand Down Expand Up @@ -53,20 +52,22 @@ private int RunEfScaffold(string connStr)
var errStr = p.StandardError.ReadToEnd();
var outStr = p.StandardOutput.ReadToEnd();

System.Console.WriteLine(outStr);
System.Console.WriteLine(errStr);
Console.WriteLine(outStr);
Console.WriteLine(errStr);

return p.ExitCode;
}

private FileContent GetEntityMap<T>()=> GetEntityMap(typeof(T).Name);
private FileContent GetEntityMap<T>()
=> GetEntityMap(typeof(T).Name);

private FileContent GetEntityMap(string className)
{
var ctxFile = File.ReadAllLines(Path.Combine(ClassDir, "TestContext.cs"));

var entityMap = new List<string>();
int? startIdx = null;
for (int i = 0; i < ctxFile.Length; i++)
for (var i = 0; i < ctxFile.Length; i++)
{
var line = ctxFile[i];

Expand Down Expand Up @@ -95,7 +96,7 @@ private FileContent GetEntityMap(string className)
private FileContent GetEntity(string className) => new FileContent(File.ReadAllLines(Path.Combine(ClassDir, $"{className}.cs")));

[Fact]
public void scaffold_db()
public void Scaffold_db()
{
string connStr;
using(var context = CreateContext())
Expand Down Expand Up @@ -128,12 +129,17 @@ class FileContent

public FileContent(IEnumerable<string> lines)
{
this.Lines = lines;
Lines = lines;
}

public void ShouldNotContain(string text, string message = null) => Assert.False(Lines.Any(l => l.Contains(text)), message);
public void ShouldContain(string text, string message = null) => Assert.True(Lines.Any(l => l.Contains(text)), message);
public void ShouldContain(Regex regex, string message = null) => Assert.True(Lines.Any(l => regex.IsMatch(l)), message);
public void ShouldNotContain(string text, string message = null)
=> Assert.False(Lines.Any(l => l.Contains(text)), message);

public void ShouldContain(string text, string message = null)
=> Assert.True(Lines.Any(l => l.Contains(text)), message);

public void ShouldContain(Regex regex, string message = null)
=> Assert.True(Lines.Any(l => regex.IsMatch(l)), message);
}
}
}
}
5 changes: 3 additions & 2 deletions EFCore.FirebirdSql.FunctionalTests/TestBasic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ public void ReproIssue28()
Name = "Ralms"
});
ctx.SaveChanges();

var peoples = ctx
.People
.AsNoTracking()
.WithNoLock()
.Where(p => p.Id > 0)
.ToList();
.ToSql();

Assert.Single(peoples);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
*/

using System;
using System.Diagnostics;
using EntityFrameworkCore.FirebirdSql.Design.Internal;
using EntityFrameworkCore.FirebirdSql.Migrations;
Expand Down Expand Up @@ -57,5 +58,8 @@ public virtual IServiceCollection AddProviderServices(IServiceCollection service
return serviceCollection.AddEntityFrameworkFirebird()
.AddSingleton<ILoggerFactory>(new TestSqlLoggerFactory());
}

public ListLoggerFactory CreateListLoggerFactory(Func<string, bool> shouldLogCategory)
=> new ListLoggerFactory(shouldLogCategory);
}
}
10 changes: 6 additions & 4 deletions EFCore.FirebirdSql/EFCore.FirebirdSql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>TRACE;DEBUG;EFCORE</DefineConstants>
<LangVersion>7.2</LangVersion>
<NoWarn>1701;1702;IDE1006</NoWarn>
<WarningsAsErrors>NU1605</WarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0-preview1-34529" PrivateAssets="none" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.0-preview1-34529" PrivateAssets="none" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="2.2.0-preview1-34529" PrivateAssets="none" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0-preview1-34866" PrivateAssets="none" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.0-preview1-34866" PrivateAssets="none" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="2.2.0-preview1-34866" PrivateAssets="none" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 8 additions & 7 deletions EFCore.FirebirdSql/Extensions/FbSharedType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ public static IEnumerable<Type> GetGenericTypeImplementations(this Type type, Ty
var typeInfo = type.GetTypeInfo();
if (!typeInfo.IsGenericTypeDefinition)
{
return (interfaceOrBaseType.GetTypeInfo().IsInterface ? typeInfo.ImplementedInterfaces : type.GetBaseTypes())
.Union(new[] { type })
.Where(
t => t.GetTypeInfo().IsGenericType
&& (t.GetGenericTypeDefinition() == interfaceOrBaseType));
return (interfaceOrBaseType.GetTypeInfo().IsInterface
? typeInfo.ImplementedInterfaces
: type.GetBaseTypes())
.Union(new[] { type })
.Where(
t => t.GetTypeInfo().IsGenericType
&& (t.GetGenericTypeDefinition() == interfaceOrBaseType));
}

return Enumerable.Empty<Type>();
Expand All @@ -108,8 +110,7 @@ public static IEnumerable<Type> GetBaseTypes(this Type type)

while (type != null)
{
yield return type;

yield return type;
type = type.GetTypeInfo().BaseType;
}
}
Expand Down
9 changes: 9 additions & 0 deletions EFCore.FirebirdSql/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Estilo", "IDE1006:Estilos de Nomenclatura", Justification = "<Pendente>", Scope = "member", Target = "~M:Microsoft.EntityFrameworkCore.FbPropertyBuilderExtensions.UseFirebirdIdentityColumn``1(Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder{``0})~Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder{``0}")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Estilo", "IDE1006:Estilos de Nomenclatura", Justification = "<Pendente>", Scope = "member", Target = "~M:Microsoft.EntityFrameworkCore.FbPropertyBuilderExtensions.UseFirebirdSequenceTrigger``1(Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder{``0})~Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder{``0}")]

0 comments on commit 5790afa

Please sign in to comment.