Skip to content

Commit 427dd15

Browse files
committed
Fix NpgsqlFactory.GetService:
- Renamed from Npgsql.EntityFrameworkLegacy to EntityFramework5.Npgsql - Added initial EntityFramework5.Npgsql.Tests
1 parent 457d349 commit 427dd15

8 files changed

Lines changed: 218 additions & 5 deletions

File tree

Npgsql.sln

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4A5A60DD-41B6-40BF-B677-227A921ECCC8}"
77
ProjectSection(SolutionItems) = preProject
@@ -18,6 +18,9 @@ EndProject
1818
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramework6.Npgsql", "src\EntityFramework6.Npgsql\EntityFramework6.Npgsql.csproj", "{3EC85CBA-5B79-11E3-8104-0022198AB089}"
1919
EndProject
2020
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramework5.Npgsql", "src\EntityFramework5.Npgsql\EntityFramework5.Npgsql.csproj", "{100998C4-5B85-11E3-911C-0022198AB089}"
21+
ProjectSection(ProjectDependencies) = postProject
22+
{E9C258D7-0D8E-4E6A-9857-5C6438591755} = {E9C258D7-0D8E-4E6A-9857-5C6438591755}
23+
EndProjectSection
2124
EndProject
2225
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Npgsql.Tests", "test\Npgsql.Tests\Npgsql.Tests.csproj", "{E9C258D7-0D8E-4E6A-9857-5C6438591755}"
2326
EndProject
@@ -33,6 +36,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramework7.Npgsql.Des
3336
EndProject
3437
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramework7.Npgsql.Design.FunctionalTests", "test\EntityFramework7.Npgsql.Design.FunctionalTests\EntityFramework7.Npgsql.Design.FunctionalTests.csproj", "{1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}"
3538
EndProject
39+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramework5.Npgsql.Tests", "test\EntityFramework5.Npgsql.Tests\EntityFramework5.Npgsql.Tests.csproj", "{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3}"
40+
EndProject
3641
Global
3742
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3843
Debug|Any CPU = Debug|Any CPU
@@ -79,6 +84,10 @@ Global
7984
{1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
8085
{1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
8186
{1410D291-C519-4E74-AE3D-6BC6C4A7C1DC}.Release|Any CPU.Build.0 = Release|Any CPU
87+
{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88+
{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
89+
{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
90+
{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3}.Release|Any CPU.Build.0 = Release|Any CPU
8291
EndGlobalSection
8392
GlobalSection(SolutionProperties) = preSolution
8493
HideSolutionNode = FALSE
@@ -94,6 +103,7 @@ Global
94103
{E1D99AD4-D88B-42BA-86DF-90B98B2E9A01} = {ED612DB1-AB32-4603-95E7-891BACA71C39}
95104
{8EDCED17-2D1D-45BE-9B61-0F715876DA94} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
96105
{1410D291-C519-4E74-AE3D-6BC6C4A7C1DC} = {ED612DB1-AB32-4603-95E7-891BACA71C39}
106+
{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3} = {ED612DB1-AB32-4603-95E7-891BACA71C39}
97107
EndGlobalSection
98108
GlobalSection(MonoDevelopProperties) = preSolution
99109
StartupItem = Npgsql.csproj

packages/repositories.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<repository path="..\src\EntityFramework7.Npgsql.Design\packages.config" />
66
<repository path="..\src\Npgsql\packages.config" />
77
<repository path="..\src\NpgsqlDdexProvider\packages.config" />
8+
<repository path="..\test\EntityFramework5.Npgsql.Tests\packages.config" />
89
<repository path="..\test\EntityFramework6.Npgsql.Tests\packages.config" />
910
<repository path="..\test\EntityFramework7.Npgsql.FunctionalTests\packages.config" />
1011
<repository path="..\test\EntityFramework7.Npgsql.Design.FunctionalTests\packages.config" />

src/Npgsql/NpgsqlFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ public object GetService(Type serviceType) {
9393
if (_legacyEntityFrameworkServices != null)
9494
return _legacyEntityFrameworkServices;
9595

96-
// First time, attempt to find the Npgsql.EntityFrameworkLegacy assembly and load the type via reflection
96+
// First time, attempt to find the EntityFramework5.Npgsql assembly and load the type via reflection
9797
var assemblyName = typeof(NpgsqlFactory).GetTypeInfo().Assembly.GetName();
98-
assemblyName.Name = "Npgsql.EntityFrameworkLegacy";
98+
assemblyName.Name = "EntityFramework5.Npgsql";
9999
Assembly npgsqlEfAssembly;
100100
try {
101101
npgsqlEfAssembly = Assembly.Load(new AssemblyName(assemblyName.FullName));
102102
} catch (Exception e) {
103-
throw new Exception("Could not load Npgsql.EntityFrameworkLegacy assembly, is it installed?", e);
103+
throw new Exception("Could not load EntityFramework5.Npgsql assembly, is it installed?", e);
104104
}
105105

106106
Type npgsqlServicesType;
107107
if ((npgsqlServicesType = npgsqlEfAssembly.GetType("Npgsql.NpgsqlServices")) == null ||
108108
npgsqlServicesType.GetProperty("Instance") == null)
109-
throw new Exception("Npgsql.EntityFrameworkLegacy assembly does not seem to contain the correct type!");
109+
throw new Exception("EntityFramework5.Npgsql assembly does not seem to contain the correct type!");
110110

111111
return _legacyEntityFrameworkServices = npgsqlServicesType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static).GetMethod.Invoke(null, new object[0]);
112112
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
5+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
6+
</configSections>
7+
<entityFramework>
8+
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
9+
<parameters>
10+
<parameter value="v12.0" />
11+
</parameters>
12+
</defaultConnectionFactory>
13+
</entityFramework>
14+
<startup>
15+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
16+
</startup>
17+
</configuration>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{4EB6FD81-6A30-4C35-AA89-BD2B0EDDAFF3}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>EntityFramework5.Npgsql.Tests</RootNamespace>
11+
<AssemblyName>EntityFramework5.Npgsql.Tests</AssemblyName>
12+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
35+
<HintPath>..\..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
36+
<Private>True</Private>
37+
</Reference>
38+
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
39+
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
40+
<Private>True</Private>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.ComponentModel.DataAnnotations" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Data.Entity" />
46+
<Reference Include="System.Xml.Linq" />
47+
<Reference Include="System.Data.DataSetExtensions" />
48+
<Reference Include="Microsoft.CSharp" />
49+
<Reference Include="System.Data" />
50+
<Reference Include="System.Xml" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<Compile Include="EntityFrameworkBasicTests.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<None Include="App.config" />
58+
<None Include="packages.config" />
59+
</ItemGroup>
60+
<ItemGroup>
61+
<ProjectReference Include="..\..\src\EntityFramework5.Npgsql\EntityFramework5.Npgsql.csproj">
62+
<Project>{100998c4-5b85-11e3-911c-0022198ab089}</Project>
63+
<Name>EntityFramework5.Npgsql</Name>
64+
</ProjectReference>
65+
<ProjectReference Include="..\..\src\Npgsql\Npgsql.csproj">
66+
<Project>{9d13b739-62b1-4190-b386-7a9547304eb3}</Project>
67+
<Name>Npgsql</Name>
68+
</ProjectReference>
69+
<ProjectReference Include="..\Npgsql.Tests\Npgsql.Tests.csproj">
70+
<Project>{e9c258d7-0d8e-4e6a-9857-5c6438591755}</Project>
71+
<Name>Npgsql.Tests</Name>
72+
</ProjectReference>
73+
</ItemGroup>
74+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
75+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
76+
Other similar extension points exist, see Microsoft.Common.targets.
77+
<Target Name="BeforeBuild">
78+
</Target>
79+
<Target Name="AfterBuild">
80+
</Target>
81+
-->
82+
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#region License
2+
// The PostgreSQL License
3+
//
4+
// Copyright (C) 2015 The Npgsql Development Team
5+
//
6+
// Permission to use, copy, modify, and distribute this software and its
7+
// documentation for any purpose, without fee, and without a written
8+
// agreement is hereby granted, provided that the above copyright notice
9+
// and this paragraph and the following two paragraphs appear in all copies.
10+
//
11+
// IN NO EVENT SHALL THE NPGSQL DEVELOPMENT TEAM BE LIABLE TO ANY PARTY
12+
// FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
13+
// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
14+
// DOCUMENTATION, EVEN IF THE NPGSQL DEVELOPMENT TEAM HAS BEEN ADVISED OF
15+
// THE POSSIBILITY OF SUCH DAMAGE.
16+
//
17+
// THE NPGSQL DEVELOPMENT TEAM SPECIFICALLY DISCLAIMS ANY WARRANTIES,
18+
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19+
// AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
20+
// ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS
21+
// TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
22+
#endregion
23+
24+
using Npgsql;
25+
using NUnit.Framework;
26+
using System.Data.Common;
27+
using Npgsql.Tests;
28+
29+
namespace EntityFramework5.Npgsql.Tests {
30+
[TestFixture]
31+
public class EntityFrameworkBasicTests : TestBase {
32+
public EntityFrameworkBasicTests(string backendVersion)
33+
: base(backendVersion) {
34+
}
35+
36+
[Test]
37+
public void GetServiceTest() {
38+
Assert.IsInstanceOf(
39+
typeof(DbProviderServices),
40+
NpgsqlFactory.Instance.GetService(typeof(System.Data.Common.DbProviderServices))
41+
);
42+
}
43+
}
44+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// Author:
3+
// Francisco Figueiredo Jr. <fxjrlists@yahoo.com>
4+
//
5+
// Copyright (C) 2002 The Npgsql Development Team
6+
// npgsql-general@gborg.postgresql.org
7+
// http://gborg.postgresql.org/project/npgsql/projdisplay.php
8+
//
9+
// This library is free software; you can redistribute it and/or
10+
// modify it under the terms of the GNU Lesser General Public
11+
// License as published by the Free Software Foundation; either
12+
// version 2.1 of the License, or (at your option) any later version.
13+
//
14+
// This library is distributed in the hope that it will be useful,
15+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
// Lesser General Public License for more details.
18+
//
19+
// You should have received a copy of the GNU Lesser General Public
20+
// License along with this library; if not, write to the Free Software
21+
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22+
23+
using System.Reflection;
24+
using System.Runtime.CompilerServices;
25+
26+
// Information about this assembly is defined by the following
27+
// attributes.
28+
//
29+
// change them to the information which is associated with the assembly
30+
// you compile.
31+
32+
[assembly: AssemblyTitle("")]
33+
[assembly: AssemblyDescription("")]
34+
[assembly: AssemblyConfiguration("")]
35+
[assembly: AssemblyCompany("")]
36+
[assembly: AssemblyProduct("")]
37+
[assembly: AssemblyCopyright("")]
38+
[assembly: AssemblyTrademark("")]
39+
[assembly: AssemblyCulture("")]
40+
41+
// The assembly version has following format :
42+
//
43+
// Major.Minor.Build.Revision
44+
//
45+
// You can specify all values by your own or you can build default build and revision
46+
// numbers with the '*' character (the default):
47+
48+
[assembly: AssemblyVersion("1.0.0.0")]
49+
50+
// The following attributes specify the key for the sign of your assembly. See the
51+
// .NET Framework documentation for more information about signing.
52+
// This is not required, if you don't want signing let these attributes like they're.
53+
[assembly: AssemblyDelaySign(false)]
54+
[assembly: AssemblyKeyFile("")]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="EntityFramework" version="5.0.0" targetFramework="net46" />
4+
<package id="NUnit" version="2.6.4" targetFramework="net45" />
5+
</packages>

0 commit comments

Comments
 (0)