From fad41140d14b941b7fb2e176495951b50f118899 Mon Sep 17 00:00:00 2001 From: Kamron Batman Date: Wed, 8 Aug 2018 23:29:14 -0700 Subject: [PATCH] Adds support for Roslyn / Mono C# 7. (#20) --- .gitignore | 336 ++------------------------------- RunUO.exe.config | 3 - Scripts/Accounting/Accounts.cs | 6 +- Scripts/Scripts.csproj | 8 +- Server/ScriptCompiler.cs | 58 ++++-- Server/Server.csproj | 19 +- Server/app.config | 25 ++- Server/packages.config | 4 + 8 files changed, 103 insertions(+), 356 deletions(-) delete mode 100644 RunUO.exe.config create mode 100644 Server/packages.config diff --git a/.gitignore b/.gitignore index 4e492e952..afdbd0888 100644 --- a/.gitignore +++ b/.gitignore @@ -1,331 +1,23 @@ -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# TypeScript v1 declaration files -typings/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -/RunUO.exe -/RunUO.pdb -/RunUO.vshost.exe +RunUO.exe +RunUO.exe.config +RunUO.pdb +RunUO.vshost.exe +RunUO.vshost.exe.config /Logs/ /Scripts/bin/ /Scripts/obj/ /Scripts/Output /Server/bin/ /Server/obj/ + +*.user +*.suo /.idea /Backups /Saves + +/packages +/.vs +/roslyn +Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll +Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml diff --git a/RunUO.exe.config b/RunUO.exe.config deleted file mode 100644 index 8805df075..000000000 --- a/RunUO.exe.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Scripts/Accounting/Accounts.cs b/Scripts/Accounting/Accounts.cs index 511fe5df1..f5258f110 100644 --- a/Scripts/Accounting/Accounts.cs +++ b/Scripts/Accounting/Accounts.cs @@ -29,9 +29,7 @@ namespace Server.Accounting public static IAccount GetAccount( string username ) { - IAccount a; - - m_Accounts.TryGetValue( username, out a ); + m_Accounts.TryGetValue( username, out IAccount a ); return a; } @@ -103,4 +101,4 @@ namespace Server.Accounting } } } -} \ No newline at end of file +} diff --git a/Scripts/Scripts.csproj b/Scripts/Scripts.csproj index 606ac45c8..3e26ba823 100644 --- a/Scripts/Scripts.csproj +++ b/Scripts/Scripts.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,7 +7,7 @@ Library false Scripts.CS - v4.0 + v4.7 512 @@ -21,6 +21,7 @@ prompt 4 false + false pdbonly @@ -30,6 +31,7 @@ prompt 4 false + false Server @@ -43,6 +45,7 @@ prompt MinimumRecommendedRules.ruleset false + false Output\ @@ -53,6 +56,7 @@ prompt MinimumRecommendedRules.ruleset false + false diff --git a/Server/ScriptCompiler.cs b/Server/ScriptCompiler.cs index e72111f28..d9545832c 100644 --- a/Server/ScriptCompiler.cs +++ b/Server/ScriptCompiler.cs @@ -219,7 +219,7 @@ namespace Server DeleteFiles( "Scripts.CS*.dll" ); - using ( CSharpCodeProvider provider = new CSharpCodeProvider() ) + using (CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp")) { string path = GetUnusedPath( "Scripts.CS" ); @@ -233,32 +233,33 @@ namespace Server if( Core.HaltOnWarning ) parms.WarningLevel = 4; -#if !MONO + if (Core.Unix) + { + parms.CompilerOptions = String.Format("{0} /nowarn:169,219,414 /recurse:Scripts/*.cs", parms.CompilerOptions); + files = new string[0]; + } + CompilerResults results = provider.CompileAssemblyFromFile( parms, files ); -#else - parms.CompilerOptions = String.Format( "{0} /nowarn:169,219,414 /recurse:Scripts/*.cs", parms.CompilerOptions ); - CompilerResults results = provider.CompileAssemblyFromFile( parms, "" ); -#endif m_AdditionalReferences.Add( path ); Display( results ); -#if !MONO - if( results.Errors.Count > 0 ) + if ( results.Errors.Count > 0 ) { - assembly = null; - return false; - } -#else - if( results.Errors.Count > 0 ) { - foreach( CompilerError err in results.Errors ) { - if ( !err.IsWarning ) { + if (!Core.Unix) { + assembly = null; + return false; + } + + foreach (CompilerError err in results.Errors) + { + if (!err.IsWarning) + { assembly = null; return false; } } } -#endif if( cache && Path.GetFileName( path ) == "Scripts.CS.dll" ) @@ -359,7 +360,7 @@ namespace Server DeleteFiles( "Scripts.VB*.dll" ); - using ( VBCodeProvider provider = new VBCodeProvider() ) + using (CodeDomProvider provider = CodeDomProvider.CreateProvider("VisualBasic")) { string path = GetUnusedPath( "Scripts.VB" ); @@ -373,15 +374,32 @@ namespace Server if( Core.HaltOnWarning ) parms.WarningLevel = 4; + if (Core.Unix) + { + parms.CompilerOptions = String.Format("{0} /nowarn:169,219,414 /recurse:Scripts/*.vb", parms.CompilerOptions); + files = new string[0]; + } + CompilerResults results = provider.CompileAssemblyFromFile( parms, files ); m_AdditionalReferences.Add( path ); Display( results ); - if( results.Errors.Count > 0 ) + if ( results.Errors.Count > 0 ) { - assembly = null; - return false; + if (!Core.Unix) { + assembly = null; + return false; + } + + foreach (CompilerError err in results.Errors) + { + if (!err.IsWarning) + { + assembly = null; + return false; + } + } } if( cache && Path.GetFileName( path ) == "Scripts.VB.dll" ) diff --git a/Server/Server.csproj b/Server/Server.csproj index fa703a21d..d8b69159e 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -1,5 +1,6 @@ - + + Debug x86 @@ -7,7 +8,7 @@ Exe false RunUO - v4.7.1 + v4.7 512 @@ -26,6 +27,8 @@ false false true + + Server @@ -85,6 +88,9 @@ false + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + @@ -242,9 +248,16 @@ + - + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/Server/app.config b/Server/app.config index 8805df075..d7600510c 100644 --- a/Server/app.config +++ b/Server/app.config @@ -1,3 +1,24 @@ - + - + + + + + + + + + + + + + + + + + + diff --git a/Server/packages.config b/Server/packages.config new file mode 100644 index 000000000..db32a4f66 --- /dev/null +++ b/Server/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file