diff --git a/.editorconfig b/.editorconfig index 2094727efb8..de5b32766c7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,6 @@ root=true [*] -end_of_line = CRLF insert_final_newline = true [*.cs] diff --git a/.gitignore b/.gitignore index 82db001cc0c..1e4b2fde7c9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ NHibernate.dll TestResult.xml .vscode .DS_Store + +.idea/ +.vs/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5862ae61601..57bca76f14f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core] ## The Build Menu -**ShowBuildMenu.bat** will be your friend throughout this journey. He's easiest to work with if you make his box bigger by following these steps: +**ShowBuildMenu.bat** will be your friend throughout this journey. A .sh version exists for Linux. It's easiest to work with if you make his box bigger by following these steps: 1. Run ShowBuildMenu.bat. 2. Right click on the title bar of the window. @@ -41,6 +41,8 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core] 4. (Optional) Run all the tests with option C or D and hopefully you will see no failing tests. The build may fail on certain databases; please ask on the mailing list if you are having trouble. 5. Before using the database for unit tests from an IDE, you'll need to create an empty database that matches your connection string. The unit test in NHibernate.TestDatabaseSetup supports some databases. If the one you have configured is supported, it will drop the database if it does already exist, then recreate it. +Compiling the solution under Linux requires installation of the [Mono package mono-complete](https://www.mono-project.com/download/stable) and of the [.NET Core SDK](https://www.microsoft.com/net/download). + ## Creating a Test Case to Verify the Issue In most cases, you will be adding your test to the NHibernate.Test project. If there is a test that only works with VisualBasic, then add it to the NHibernate.Test.VisualBasic project instead. diff --git a/ShowBuildMenu.bat b/ShowBuildMenu.bat index 2e7d4e10380..29fe9622a7b 100644 --- a/ShowBuildMenu.bat +++ b/ShowBuildMenu.bat @@ -2,11 +2,16 @@ pushd %~dp0 set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0 -set BUILDTOOL="%~dp0Tools\BuildTool\bin\Release\BuildTool.exe" +set BUILD_TOOL_PATH=%~dp0Tools\BuildTool\bin\BuildTool.dll +set BUILDTOOL=dotnet %BUILD_TOOL_PATH% set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations set CURRENT_CONFIGURATION=%~dp0current-test-configuration set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe" +if not exist %BUILD_TOOL_PATH% ( + dotnet build %~dp0Tools\BuildTool\BuildTool.sln -c Release -o bin +) + :main-menu echo ========================= NHIBERNATE BUILD MENU ========================== echo --- TESTING --- diff --git a/ShowBuildMenu.sh b/ShowBuildMenu.sh new file mode 100755 index 00000000000..4fef99c721a --- /dev/null +++ b/ShowBuildMenu.sh @@ -0,0 +1,261 @@ +#!/bin/sh + +BUILD_TOOL_PATH="./Tools/BuildTool/bin/BuildTool.dll" +BUILD_TOOL="dotnet $BUILD_TOOL_PATH" +AVAILABLE_CONFIGURATIONS="available-test-configurations" +CONFIG_NAME="" +TEST_PLATFORM="" +LIB_FILES="" +LIB_FILES2="" +CURRENT_CONFIGURATION="./current-test-configuration" +OPTION=0 +async_generator_path="" + +if [ ! -f $BUILD_TOOL_PATH ] +then + dotnet build ./Tools/BuildTool/BuildTool.sln -c Release -o bin +fi + +buildDebug(){ + dotnet build ./src/NHibernate.sln + echo "." + echo "Assuming the build succeeded, your results will be in the build folder." + echo "." + mainMenu +} + +buildRelease(){ + dotnet build ./src/NHibernate.sln -c Release + echo "." + echo "Assuming the build succeeded, your results will be in the build folder." + echo "." + mainMenu +} + +testActivate(){ + FILE_TEMP="folder.tmp" + + $BUILD_TOOL pick-folder $AVAILABLE_CONFIGURATIONS $FILE_TEMP "Which test configuration should be activated?" + + if [ -d $CURRENT_CONFIGURATION ] + then + rm -r $CURRENT_CONFIGURATION/ + fi + + CURRENT_FOLDER=$(pwd) + INFORMATION=$(cat $CURRENT_FOLDER/$FILE_TEMP) + cp -r $INFORMATION/ $CURRENT_CONFIGURATION + + rm $FILE_TEMP + + echo "Configuration activated." + + mainMenu +} + +testSetupGeneric() { + echo "Enter a name for your test configuration or press enter to use default name:" + read CFGNAME + if [ $CFGNAME = ""] + then + CFGNAME="$CONFIG_NAME-$TEST_PLATFORM" + echo $CFGNAME + fi + + mkdir -p $AVAILABLE_CONFIGURATIONS/$CFGNAME + + if [ ! "$LIB_FILES" ] + then + cp $LIB_FILES $AVAILABLE_CONFIGURATIONS/$CFGNAME + + if [ ! "$LIB_FILES2" ] + then + cp $LIB_FILES2 $AVAILABLE_CONFIGURATIONS/$CFGNAME + fi + fi + + cp "src/NHibernate.Config.Templates/$CONFIG_NAME.cfg.xml" "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml" + echo "Done setting up files. Please edit the connection string in file:" + echo "$AVAILABLE_CONFIGURATIONS/$CFGNAME/hibernate.cfg.xml" + echo "When you're done, don't forget to activate the configuration through the menu." + mainMenu +} + +testSetupSqlServer() { + CONFIG_NAME="MSSQL" + TEST_PLATFORM="AnyCPU" + LIB_FILES="" + LIB_FILES2="" + testSetupGeneric +} + +testSetupFirebird() { + CONFIG_NAME="FireBird" + TEST_PLATFORM="AnyCPU" + LIB_FILES="" + LIB_FILES2="" + testSetupGeneric +} + +testSetupSqlite() { + CONFIG_NAME="SQLite" + TEST_PLATFORM="AnyCPU" + LIB_FILES="" + LIB_FILES2=""e + testSetupGeneric +} + +testSetupPostgresql() { + CONFIG_NAME="PostgreSQL" + TEST_PLATFORM="AnyCPU" + LIB_FILES="" + LIB_FILES2="" + testSetupGeneric +} + +testSetupMysql() { + CONFIG_NAME="MySql" + TEST_PLATFORM="AnyCPU" + LIB_FILES="" + LIB_FILES2="" + testSetupGeneric +} + +testSetupMenu() { + echo "A. Add a test configuration for SQL Server." + echo "B. Add a test configuration for Firebird." + echo "C. Add a test configuration for SQLite." + echo "D. Add a test configuration for PostgreSQL." + echo "E. Add a test configuration for MySql." + echo "." + echo "X. Exit to main menu." + echo "." + + $BUILD_TOOL prompt ABCDEX + + OPTION=$? + if [ $OPTION -eq 5 ] + then + echo "Main menu" + mainMenu + elif [ $OPTION -eq 4 ] + then + echo "MySQL" + testSetupMysql + mainMenu + elif [ $OPTION -eq 3 ] + then + echo "PostgreSQL" + testSetupPostgresql + mainMenu + elif [ $OPTION -eq 2 ] + then + echo "Sqlite" + testSetupSqlite + mainMenu + elif [ $OPTION -eq 1 ] + then + echo "Firebird" + testSetupFirebird + mainMenu + elif [ $OPTION -eq 0 ] + then + echo "SQL Server" + testSetupSqlServer + mainMenu + fi +} + +testRun(){ + dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj -f netcoreapp2.0 + dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj -f netcoreapp2.0 + mainMenu +} + +generateAsync(){ + dotnet msbuild /t:Restore ./src/NHibernate.sln + + getAsyncGeneratorPath + cd src + mono ../"$async_generator_path" + cd .. + + mainMenu +} + +getAsyncGeneratorPath(){ + if [ "$async_generator_path" ] + then + return + fi + + cd Tools + + if [ ! -f nuget.exe ] + then + wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe + fi + + async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools" + + if [ ! -d $async_generator_path ] + then + mono nuget.exe install + fi + + if [ ! -f $async_generator_path/SQLitePCLRaw.core.dll ] + then + # This "hidden" dependency causes a failure under some Mono setup, add it explicitly + mono nuget.exe install SQLitePCLRaw.core -Version 1.0.0 + cp SQLitePCLRaw.core.1.0.0/lib/net45/SQLitePCLRaw.core.dll $async_generator_path/ + fi + + async_generator_path="Tools/$async_generator_path/AsyncGenerator.CommandLine.exe" + + cd .. +} + +mainMenu() { + echo "========================= NHIBERNATE BUILD MENU ==========================" + echo "--- TESTING ---" + echo "A. (Step 1) Set up a new test configuration for a particular database." + echo "B. (Step 2) Activate a test configuration." + echo "C. (Step 3) Run tests." + echo "." + echo "--- BUILD ---" + echo "E. Build NHibernate (Debug)" + echo "F. Build NHibernate (Release)" + echo "." + echo "--- Code generation ---" + echo "H. Generate async code (Generates files in Async sub-folders)" + echo "." + echo "--- Exit ---" + echo "X. Make the beautiful build menu go away." + echo "." + + $BUILD_TOOL prompt ABCEFHX + + OPTION=$? + + if [ $OPTION -eq 5 ] + then + generateAsync + elif [ $OPTION -eq 4 ] + then + buildRelease + elif [ $OPTION -eq 3 ] + then + buildDebug + elif [ $OPTION -eq 2 ] + then + testRun + elif [ $OPTION -eq 1 ] + then + testActivate + elif [ $OPTION -eq 0 ] + then + testSetupMenu + fi +} + +mainMenu diff --git a/Tools/.gitignore b/Tools/.gitignore index 0de96ce7aaa..1128a77fed4 100644 --- a/Tools/.gitignore +++ b/Tools/.gitignore @@ -2,4 +2,5 @@ nuget.exe NUnit.* vswhere.* CSharpAsyncGenerator.CommandLine.* -gitreleasemanager.* \ No newline at end of file +gitreleasemanager.* +SQLitePCLRaw.core.* diff --git a/Tools/BuildTool/.gitignore b/Tools/BuildTool/.gitignore index 7fb1ef81b0e..1c6b6486932 100644 --- a/Tools/BuildTool/.gitignore +++ b/Tools/BuildTool/.gitignore @@ -3,6 +3,8 @@ *.user *.suo .vs/ -bin/Debug/ +bin/ obj/ -*.vshost.* \ No newline at end of file +*.vshost.* +.idea/ +.vs/ \ No newline at end of file diff --git a/Tools/BuildTool/BuildTool.csproj b/Tools/BuildTool/BuildTool.csproj index 31bf4dcdb3d..8fa67b5e0c0 100644 --- a/Tools/BuildTool/BuildTool.csproj +++ b/Tools/BuildTool/BuildTool.csproj @@ -1,59 +1,6 @@ - - + - Debug - x86 - 8.0.30703 - 2.0 - {9F599EF4-F977-4063-9141-3D95359EE076} Exe - Properties - BuildTool - BuildTool - v4.0 - Client - 512 + netcoreapp2.0 - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Tools/BuildTool/BuildTool.sln b/Tools/BuildTool/BuildTool.sln index 26551a5a0b6..649b09aa74a 100644 --- a/Tools/BuildTool/BuildTool.sln +++ b/Tools/BuildTool/BuildTool.sln @@ -1,20 +1,34 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildTool", "BuildTool.csproj", "{9F599EF4-F977-4063-9141-3D95359EE076}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildTool", "BuildTool.csproj", "{1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9F599EF4-F977-4063-9141-3D95359EE076}.Debug|x86.ActiveCfg = Debug|x86 - {9F599EF4-F977-4063-9141-3D95359EE076}.Debug|x86.Build.0 = Debug|x86 - {9F599EF4-F977-4063-9141-3D95359EE076}.Release|x86.ActiveCfg = Release|x86 - {9F599EF4-F977-4063-9141-3D95359EE076}.Release|x86.Build.0 = Release|x86 - EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Debug|x64.ActiveCfg = Debug|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Debug|x64.Build.0 = Debug|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Debug|x86.ActiveCfg = Debug|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Debug|x86.Build.0 = Debug|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Release|Any CPU.Build.0 = Release|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Release|x64.ActiveCfg = Release|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Release|x64.Build.0 = Release|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Release|x86.ActiveCfg = Release|Any CPU + {1973E971-94A9-4A8A-B9C1-B4F8E0C5E3BF}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection EndGlobal diff --git a/Tools/BuildTool/Program.cs b/Tools/BuildTool/Program.cs index 79f7011c7f0..c40d1e456f4 100644 --- a/Tools/BuildTool/Program.cs +++ b/Tools/BuildTool/Program.cs @@ -1,56 +1,63 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace BuildTool { - class Program - { - static int Main(string[] args) - { - string command = args[0]; - - if (command == "pick-folder") - { - string[] folders = Directory.GetDirectories(args[1]); - for (int i = 0; i < folders.Length; i++) - { - Console.WriteLine((char)('A' + i) + ": " + Path.GetFileName(folders[i])); - } - while (true) - { - Console.WriteLine(args[3]); - var key = Console.ReadKey(); - Console.WriteLine(); - if (key.KeyChar >= 'A' && key.KeyChar <= 'Z' || key.KeyChar >= 'a' && key.KeyChar <= 'z') - { - int index = key.KeyChar.ToString().ToUpper()[0] - 'A'; - File.WriteAllText(args[2], folders[index]); - break; - } - } - - return 0; - } - else if (command == "prompt") - { - while(true) - { - Console.WriteLine("[" + string.Join(", ", args[1].ToCharArray().Select(c => c.ToString()).ToArray()) + "]?"); - char[] characters = args[1].ToLower().ToCharArray(); - var key = char.ToLower(Console.ReadKey().KeyChar); - Console.WriteLine(); - if (characters.Contains(key)) - return characters.ToList().IndexOf(key); - } - } - else - { - Console.WriteLine("Invalid command: " + command); - return 255; - } - } - } + public static class Program + { + public static int Main(string[] args) + { + var command = args[0]; + + switch (command) + { + case "pick-folder": + var folders = Directory.GetDirectories(args[1]); + for (var i = 0; i < folders.Length; i++) + { + Console.WriteLine((char) ('A' + i) + ": " + Path.GetFileName(folders[i])); + } + + var sb = new StringBuilder(); + for (var i = 3; i < args.Length; i++) + sb.Append(args[i]); + var remainingArgs = sb.ToString(); + + while (true) + { + Console.WriteLine(remainingArgs); + var key = Console.ReadKey(); + Console.WriteLine(); + + if (char.IsLetter(key.KeyChar)) + { + var index = key.KeyChar.ToString().ToUpper()[0] - 'A'; + File.WriteAllText(args[2], folders[index]); + break; + } + } + + return 0; + + case "prompt": + var characters = args[1].ToUpper().ToList(); + while (true) + { + Console.WriteLine($"[{string.Join(", ", characters)}]?"); + var key = char.ToUpper(Console.ReadKey().KeyChar); + Console.WriteLine(); + if (characters.Contains(key)) + { + return characters.IndexOf(key); + } + } + + default: + Console.WriteLine($"Invalid command: {command}"); + return 255; + } + } + } } diff --git a/Tools/BuildTool/app.config b/Tools/BuildTool/app.config deleted file mode 100644 index 2f7cce784b9..00000000000 --- a/Tools/BuildTool/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Tools/BuildTool/bin/Release/BuildTool.exe b/Tools/BuildTool/bin/Release/BuildTool.exe deleted file mode 100644 index cd21b6f7821..00000000000 Binary files a/Tools/BuildTool/bin/Release/BuildTool.exe and /dev/null differ diff --git a/Tools/BuildTool/bin/Release/BuildTool.exe.config b/Tools/BuildTool/bin/Release/BuildTool.exe.config deleted file mode 100644 index 2f7cce784b9..00000000000 --- a/Tools/BuildTool/bin/Release/BuildTool.exe.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Tools/BuildTool/bin/Release/BuildTool.pdb b/Tools/BuildTool/bin/Release/BuildTool.pdb deleted file mode 100644 index 1bfb93cb15d..00000000000 Binary files a/Tools/BuildTool/bin/Release/BuildTool.pdb and /dev/null differ diff --git a/Tools/BuildTool/properties/AssemblyInfo.cs b/Tools/BuildTool/properties/AssemblyInfo.cs deleted file mode 100644 index 1ab214a8acf..00000000000 --- a/Tools/BuildTool/properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +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: AssemblyTitle("BuildTool")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("BuildTool")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 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("d4504371-aeb8-4a01-9617-68965fb3af68")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")]