From dba91980d0d51fb0c65687c7f28dde74a6f0a537 Mon Sep 17 00:00:00 2001 From: Vitalii Fedorchenko Date: Tue, 26 May 2020 12:14:04 +0300 Subject: [PATCH] Migrate tests and examples to .NET Core 3.1 (LTS) --- .travis.yml | 4 +-- appveyor.yml | 2 +- .../DataSetGenericDataAdapter.csproj | 8 ++--- .../Properties/launchSettings.json | 8 ----- .../MySqlDemo.DbMetadata.csproj | 10 ++---- .../Properties/AssemblyInfo.cs | 19 ----------- .../Properties/AssemblyInfo.cs | 19 ----------- .../Properties/launchSettings.json | 8 ----- .../SqliteDemo.CommandBuilder.csproj | 10 ++---- .../Properties/AssemblyInfo.cs | 19 ----------- .../Properties/launchSettings.json | 8 ----- .../SqliteDemo.DataAdapter.csproj | 10 ++---- examples/SqliteDemo.GraphQLApi/Program.cs | 4 +++ .../SqliteDemo.GraphQLAPI.csproj | 31 +++-------------- examples/SqliteDemo.GraphQLApi/Startup.cs | 28 ++++++++++----- examples/SqliteDemo.MVCApplication/Program.cs | 2 ++ .../SqliteDemo.MVCApplication.csproj | 32 ++++-------------- examples/SqliteDemo.MVCApplication/Startup.cs | 20 +++++++---- .../mvcapp_database.db | Bin 28672 -> 28672 bytes .../SqliteDemo.SqlLogging.csproj | 6 ++-- examples/SqliteDemo.WebApi/Program.cs | 1 + .../SqliteDemo.WebApi.csproj | 29 +++------------- examples/SqliteDemo.WebApi/Startup.cs | 24 ++++++++----- src/NReco.Data.Tests/NReco.Data.Tests.csproj | 17 +++------- .../Properties/AssemblyInfo.cs | 19 ----------- 25 files changed, 94 insertions(+), 244 deletions(-) delete mode 100644 examples/DataSetGenericDataAdapter/Properties/launchSettings.json delete mode 100644 examples/MySqlDemo.DbMetadata/Properties/AssemblyInfo.cs delete mode 100644 examples/SqliteDemo.CommandBuilder/Properties/AssemblyInfo.cs delete mode 100644 examples/SqliteDemo.CommandBuilder/Properties/launchSettings.json delete mode 100644 examples/SqliteDemo.DataAdapter/Properties/AssemblyInfo.cs delete mode 100644 examples/SqliteDemo.DataAdapter/Properties/launchSettings.json delete mode 100644 src/NReco.Data.Tests/Properties/AssemblyInfo.cs diff --git a/.travis.yml b/.travis.yml index 07c9821..29f6a6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required -dist: trusty -dotnet: 2.1.300 +dist: xenial +dotnet: 3.1 solution: src/NReco.Data.sln script: diff --git a/appveyor.yml b/appveyor.yml index 2043c5a..a2dc852 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.{build} -os: Visual Studio 2017 +os: Visual Studio 2019 configuration: Release platform: Any CPU diff --git a/examples/DataSetGenericDataAdapter/DataSetGenericDataAdapter.csproj b/examples/DataSetGenericDataAdapter/DataSetGenericDataAdapter.csproj index 314af23..43a4786 100644 --- a/examples/DataSetGenericDataAdapter/DataSetGenericDataAdapter.csproj +++ b/examples/DataSetGenericDataAdapter/DataSetGenericDataAdapter.csproj @@ -2,13 +2,13 @@ Exe - netcoreapp2.1 + netcoreapp3.1 - - - + + + diff --git a/examples/DataSetGenericDataAdapter/Properties/launchSettings.json b/examples/DataSetGenericDataAdapter/Properties/launchSettings.json deleted file mode 100644 index 7969c66..0000000 --- a/examples/DataSetGenericDataAdapter/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "DataSetGenericDataAdapter": { - "commandName": "Project", - "workingDirectory": "$(ProjectDir)" - } - } -} \ No newline at end of file diff --git a/examples/MySqlDemo.DbMetadata/MySqlDemo.DbMetadata.csproj b/examples/MySqlDemo.DbMetadata/MySqlDemo.DbMetadata.csproj index b94b691..59a71b7 100644 --- a/examples/MySqlDemo.DbMetadata/MySqlDemo.DbMetadata.csproj +++ b/examples/MySqlDemo.DbMetadata/MySqlDemo.DbMetadata.csproj @@ -1,18 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 MySqlDemo.DbMetadata Exe - MySqlDemo.DbMetadata - false - false - false - - + + diff --git a/examples/MySqlDemo.DbMetadata/Properties/AssemblyInfo.cs b/examples/MySqlDemo.DbMetadata/Properties/AssemblyInfo.cs deleted file mode 100644 index 9a7f641..0000000 --- a/examples/MySqlDemo.DbMetadata/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("MySqlDemo.DbMetadata")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2b8eb4b6-4896-4970-b5ea-6d324824a541")] diff --git a/examples/SqliteDemo.CommandBuilder/Properties/AssemblyInfo.cs b/examples/SqliteDemo.CommandBuilder/Properties/AssemblyInfo.cs deleted file mode 100644 index f15ccc6..0000000 --- a/examples/SqliteDemo.CommandBuilder/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SqliteDemo")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e138270b-84b3-4a0c-82e6-ce283f9d53ea")] diff --git a/examples/SqliteDemo.CommandBuilder/Properties/launchSettings.json b/examples/SqliteDemo.CommandBuilder/Properties/launchSettings.json deleted file mode 100644 index 4357ecc..0000000 --- a/examples/SqliteDemo.CommandBuilder/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "SqliteDemo.CommandBuilder": { - "commandName": "Project", - "workingDirectory": "$(ProjectDir)" - } - } -} \ No newline at end of file diff --git a/examples/SqliteDemo.CommandBuilder/SqliteDemo.CommandBuilder.csproj b/examples/SqliteDemo.CommandBuilder/SqliteDemo.CommandBuilder.csproj index e8a73b4..b76336a 100644 --- a/examples/SqliteDemo.CommandBuilder/SqliteDemo.CommandBuilder.csproj +++ b/examples/SqliteDemo.CommandBuilder/SqliteDemo.CommandBuilder.csproj @@ -1,18 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 SqliteDemo.CommandBuilder Exe - SqliteDemo.CommandBuilder - false - false - false - - + + diff --git a/examples/SqliteDemo.DataAdapter/Properties/AssemblyInfo.cs b/examples/SqliteDemo.DataAdapter/Properties/AssemblyInfo.cs deleted file mode 100644 index 134557e..0000000 --- a/examples/SqliteDemo.DataAdapter/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SqliteDemo.DataAdapter")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("424df75e-b560-41a7-acef-abfdb620f8ea")] diff --git a/examples/SqliteDemo.DataAdapter/Properties/launchSettings.json b/examples/SqliteDemo.DataAdapter/Properties/launchSettings.json deleted file mode 100644 index e90dc95..0000000 --- a/examples/SqliteDemo.DataAdapter/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "SqliteDemo.DataAdapter": { - "commandName": "Project", - "workingDirectory": "$(ProjectDir)" - } - } -} \ No newline at end of file diff --git a/examples/SqliteDemo.DataAdapter/SqliteDemo.DataAdapter.csproj b/examples/SqliteDemo.DataAdapter/SqliteDemo.DataAdapter.csproj index 5cdb485..24a0dbd 100644 --- a/examples/SqliteDemo.DataAdapter/SqliteDemo.DataAdapter.csproj +++ b/examples/SqliteDemo.DataAdapter/SqliteDemo.DataAdapter.csproj @@ -1,19 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 SqliteDemo.DataAdapter Exe - SqliteDemo.DataAdapter - false - false - false - + - + diff --git a/examples/SqliteDemo.GraphQLApi/Program.cs b/examples/SqliteDemo.GraphQLApi/Program.cs index ce5eaf7..6b03374 100644 --- a/examples/SqliteDemo.GraphQLApi/Program.cs +++ b/examples/SqliteDemo.GraphQLApi/Program.cs @@ -8,6 +8,9 @@ namespace SqliteDemo.GraphQLApi { + // Simple grapql API based on Graphql.NET + NReco.Data + // If you're looking for production-ready Graphql-to-SQL engine try this component: + // https://www.nrecosite.com/graphql_to_sql_database.aspx public class Program { public static void Main(string[] args) @@ -16,6 +19,7 @@ public static void Main(string[] args) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() + .UseIIS() .UseStartup() .Build(); diff --git a/examples/SqliteDemo.GraphQLApi/SqliteDemo.GraphQLAPI.csproj b/examples/SqliteDemo.GraphQLApi/SqliteDemo.GraphQLAPI.csproj index e762bd8..f5fef4d 100644 --- a/examples/SqliteDemo.GraphQLApi/SqliteDemo.GraphQLAPI.csproj +++ b/examples/SqliteDemo.GraphQLApi/SqliteDemo.GraphQLAPI.csproj @@ -1,34 +1,13 @@ - + - netcoreapp2.1 - true - SqliteDemo.GraphQLAPI - Exe - SqliteDemo.GraphQLAPI + netcoreapp3.1 - - PreserveNewest - - - - - - - - - - - - - - - - - - + + + diff --git a/examples/SqliteDemo.GraphQLApi/Startup.cs b/examples/SqliteDemo.GraphQLApi/Startup.cs index c527124..adf90f2 100644 --- a/examples/SqliteDemo.GraphQLApi/Startup.cs +++ b/examples/SqliteDemo.GraphQLApi/Startup.cs @@ -18,11 +18,15 @@ using SqliteDemo.GraphQLApi.Db.GraphQL; namespace SqliteDemo.GraphQLApi { + + // Simple grapql API based on Graphql.NET + NReco.Data + // If you're looking for production-ready Graphql-to-SQL engine try this component: + // https://www.nrecosite.com/graphql_to_sql_database.aspx public class Startup { const string dbConnectionFile = "northwind.db"; protected string ApplicationPath; - public Startup(IHostingEnvironment env) { + public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) @@ -39,13 +43,22 @@ public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - // let's inject NReco.Data services (based on EF DBConnection) + services.AddLogging(loggingBuilder => { + var loggingSection = Configuration.GetSection("Logging"); + loggingBuilder.AddConfiguration(loggingSection); + loggingBuilder.AddConsole(); + }); + + // NReco.Data services InjectNRecoDataService(services); - // + InjectGraphQLSchema(services); services.AddScoped(); + // Add framework services. - services.AddMvc(); + services.AddMvc(options => { + options.EnableEndpointRouting = false; + }); } protected void InjectGraphQLSchema(IServiceCollection services) { @@ -84,11 +97,8 @@ public class Startup { } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - //app.UseDeveloperExceptionPage(); - //app.UseBrowserLink(); + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { + app.UseDefaultFiles(); app.UseStaticFiles(); diff --git a/examples/SqliteDemo.MVCApplication/Program.cs b/examples/SqliteDemo.MVCApplication/Program.cs index de84a7f..1942ba2 100644 --- a/examples/SqliteDemo.MVCApplication/Program.cs +++ b/examples/SqliteDemo.MVCApplication/Program.cs @@ -7,6 +7,7 @@ namespace SqliteDemo.MVCApplication { + // CRUD app that uses both EF Core AND NReco.Data public class Program { public static void Main(string[] args) @@ -15,6 +16,7 @@ public static void Main(string[] args) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() + .UseIIS() .UseStartup() .Build(); diff --git a/examples/SqliteDemo.MVCApplication/SqliteDemo.MVCApplication.csproj b/examples/SqliteDemo.MVCApplication/SqliteDemo.MVCApplication.csproj index c069796..e60bfca 100644 --- a/examples/SqliteDemo.MVCApplication/SqliteDemo.MVCApplication.csproj +++ b/examples/SqliteDemo.MVCApplication/SqliteDemo.MVCApplication.csproj @@ -1,11 +1,7 @@ - + - netcoreapp2.1 - true - SqliteDemo.MVCApplication - Exe - SqliteDemo.MVCApplication + netcoreapp3.1 @@ -15,29 +11,15 @@ - - + + All - - - - - - - - - - - - + - - - - - + + diff --git a/examples/SqliteDemo.MVCApplication/Startup.cs b/examples/SqliteDemo.MVCApplication/Startup.cs index 734de74..1e67f81 100644 --- a/examples/SqliteDemo.MVCApplication/Startup.cs +++ b/examples/SqliteDemo.MVCApplication/Startup.cs @@ -21,6 +21,7 @@ namespace SqliteDemo.MVCApplication { + // CRUD app that uses both EF Core AND NReco.Data public class Startup { const string dbConnectionFile = "mvcapp_database.db"; @@ -43,7 +44,13 @@ public Startup(IHostingEnvironment env) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - var dbConnectionString = String.Format("Filename={0}", Path.Combine(ApplicationPath, dbConnectionFile)); + services.AddLogging(loggingBuilder => { + var loggingSection = Configuration.GetSection("Logging"); + loggingBuilder.AddConfiguration(loggingSection); + loggingBuilder.AddConsole(); + }); + + var dbConnectionString = String.Format("Filename={0}", Path.Combine(ApplicationPath, dbConnectionFile)); // Add EF framework services. services.AddDbContext( options => options.UseSqlite( @@ -55,8 +62,10 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); // Add framework services. - services.AddMvc(); - } + services.AddMvc(options => { + options.EnableEndpointRouting = false; + }); + } protected void InjectNRecoDataService(IServiceCollection services) { @@ -96,11 +105,8 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - app.UseDeveloperExceptionPage(); app.UseStaticFiles(); diff --git a/examples/SqliteDemo.MVCApplication/mvcapp_database.db b/examples/SqliteDemo.MVCApplication/mvcapp_database.db index b4634212c6de0ae76b10efb1f85af7faf4b2c886..27a3f751e266be5ce27d3634e8b3e3049229a70e 100644 GIT binary patch delta 106 zcmV-w0G0oM-~oW(0gxL37Lgo71r`7x m1PBrY1ON>K1ppHj0dsS6RAqB?0<)!VTLH2_{|^BJqEH}Z9Tflo diff --git a/examples/SqliteDemo.SqlLogging/SqliteDemo.SqlLogging.csproj b/examples/SqliteDemo.SqlLogging/SqliteDemo.SqlLogging.csproj index 9eb7217..4479941 100644 --- a/examples/SqliteDemo.SqlLogging/SqliteDemo.SqlLogging.csproj +++ b/examples/SqliteDemo.SqlLogging/SqliteDemo.SqlLogging.csproj @@ -2,12 +2,12 @@ Exe - netcoreapp2.1 + netcoreapp3.1 - - + + diff --git a/examples/SqliteDemo.WebApi/Program.cs b/examples/SqliteDemo.WebApi/Program.cs index b4410a6..50f2cc6 100644 --- a/examples/SqliteDemo.WebApi/Program.cs +++ b/examples/SqliteDemo.WebApi/Program.cs @@ -16,6 +16,7 @@ public static void Main(string[] args) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() + .UseIIS() .UseStartup() .Build(); diff --git a/examples/SqliteDemo.WebApi/SqliteDemo.WebApi.csproj b/examples/SqliteDemo.WebApi/SqliteDemo.WebApi.csproj index 9f0cace..ebaa033 100644 --- a/examples/SqliteDemo.WebApi/SqliteDemo.WebApi.csproj +++ b/examples/SqliteDemo.WebApi/SqliteDemo.WebApi.csproj @@ -1,34 +1,13 @@ - netcoreapp2.1 - true - SqliteDemo.WebApi - Exe - SqliteDemo.WebApi + netcoreapp3.1 - - PreserveNewest - - - - - - - - - - - - - - - - - - + + + diff --git a/examples/SqliteDemo.WebApi/Startup.cs b/examples/SqliteDemo.WebApi/Startup.cs index 30b09c4..883ad6d 100644 --- a/examples/SqliteDemo.WebApi/Startup.cs +++ b/examples/SqliteDemo.WebApi/Startup.cs @@ -13,9 +13,9 @@ namespace SqliteDemo.WebApi { public class Startup { - IHostingEnvironment HostingEnv; + IWebHostEnvironment HostingEnv; - public Startup(IHostingEnvironment env) + public Startup(IWebHostEnvironment env) { HostingEnv = env; var builder = new ConfigurationBuilder() @@ -32,8 +32,19 @@ public Startup(IHostingEnvironment env) // This method gets called by the runtime. Use this method to add services to the container public void ConfigureServices(IServiceCollection services) { - - services.AddMvc(); + services.AddLogging(loggingBuilder => { + var loggingSection = Configuration.GetSection("Logging"); + loggingBuilder.AddConfiguration(loggingSection); + loggingBuilder.AddConsole(); + }); + + services.AddMvc(options => { + options.EnableEndpointRouting = false; + }).AddNewtonsoftJson(options => { + options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; + options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); + options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter { CamelCaseText = false }); + }); // add NReco.Data services var sqliteDbPath = Path.Combine( HostingEnv.ContentRootPath, "northwind.db"); @@ -41,11 +52,8 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - app.UseDefaultFiles(); app.UseStaticFiles(); app.UseMvc(); diff --git a/src/NReco.Data.Tests/NReco.Data.Tests.csproj b/src/NReco.Data.Tests/NReco.Data.Tests.csproj index 596ca91..8fb1d87 100644 --- a/src/NReco.Data.Tests/NReco.Data.Tests.csproj +++ b/src/NReco.Data.Tests/NReco.Data.Tests.csproj @@ -1,13 +1,8 @@  - netcoreapp2.1 - NReco.Data.Tests - NReco.Data.Tests - true - false - false - false + netcoreapp3.1 + false @@ -19,13 +14,9 @@ - - + + - - latest - - diff --git a/src/NReco.Data.Tests/Properties/AssemblyInfo.cs b/src/NReco.Data.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 9bd30e6..0000000 --- a/src/NReco.Data.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NReco.Data.Tests")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("dc35c7b5-853c-4953-91f0-820e1437ce74")]