Skip to content

Commit

Permalink
Merge #3929 Modernize build system and .NET platform targets
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 19, 2023
2 parents 3da1f04 + f7f40aa commit e67b9ee
Show file tree
Hide file tree
Showing 277 changed files with 1,884 additions and 1,632 deletions.
51 changes: 51 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[*.cs]
dotnet_analyzer_diagnostic.category-Style.severity = warning
dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning

# Using `var` is good
dotnet_diagnostic.IDE0008.severity = none

# Don't need to enumerate every case for `switch` with `default`
dotnet_diagnostic.IDE0010.severity = none

# Don't "simplify" if statements that throw
dotnet_diagnostic.IDE0016.severity = none

# Expression bodies are good for methods
dotnet_diagnostic.IDE0022.severity = none

# Expression bodies are fine for operators
dotnet_diagnostic.IDE0024.severity = none

# Collection initialization simplification affects JObject, which is dumb
dotnet_diagnostic.IDE0028.severity = none

# "auto" properties seem pretty useless
dotnet_diagnostic.IDE0032.severity = none

# "local functions" are just weird, no thank you
dotnet_diagnostic.IDE0039.severity = none

# "if" statements should only be "simplified" if they're pure functional,
# and these checks don't know that
dotnet_diagnostic.IDE0045.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.IDE0270.severity = none

# We use "unnecessary" parentheses for clarity
dotnet_diagnostic.IDE0047.severity = none

# Let me keep my extra spaces for aligning things
dotnet_diagnostic.IDE0055.severity = none

# OK to call functions that return values and not use them
dotnet_diagnostic.IDE0058.severity = none

# A `using` inside a namespace is useful as a typedef
dotnet_diagnostic.IDE0065.severity = none

# Allow namespaces to be independent of folder names
dotnet_diagnostic.IDE0130.severity = none

# Who cares if it's a JSON formatted string, in a test?
dotnet_diagnostic.JSON002.severity = none
27 changes: 21 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
types:
- opened
- synchronize
- reopened

jobs:
build:
Expand All @@ -14,8 +17,14 @@ jobs:
strategy:
fail-fast: false
matrix:
mono: ['6.8', '6.10', '6.12', 'latest']
configuration: [Debug, Release]
mono:
- latest
- '6.12'
- '6.10'
- '6.8'
configuration:
- Debug
- Release

container:
image: mono:${{ matrix.mono }}
Expand All @@ -27,6 +36,10 @@ jobs:
run: |
apt-get update || true
apt-get install -y apt-transport-https
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7'
- name: Installing build dependencies
run: apt-get update && apt-get install -y git
- name: Install runtime dependencies
Expand Down Expand Up @@ -66,7 +79,7 @@ jobs:
curl -O https://raw.githubusercontent.com/KSP-CKAN/NetKAN/master/NetKAN/ZeroMiniAVC.netkan && \
mono netkan.exe ZeroMiniAVC.netkan
"
if: matrix.configuration == 'release' && ( matrix.mono == '6.8' || matrix.mono == 'latest' )
if: matrix.configuration == 'release'

- name: Upload ckan.exe artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -95,14 +108,16 @@ jobs:
strategy:
fail-fast: false
matrix:
configuration: [Debug_NetCore, Release_NetCore]
configuration:
- Debug_NetCore
- Release_NetCore

steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '5.0.x'
dotnet-version: '7'
- name: Restore cache for _build/tools
uses: actions/cache@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
echo 'odd_build=true' >> $GITHUB_OUTPUT
fi
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7'
- name: Installing build dependencies
run: apt-get update && apt-get install -y git make sed gzip fakeroot lintian dpkg-dev gpg createrepo
- name: Installing runtime dependencies
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7'
- name: Installing build dependencies
run: apt-get update && apt-get install -y git make sed libplist-utils xorriso gzip fakeroot lintian rpm wget jq dpkg-dev gpg createrepo
- name: Installing runtime dependencies
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/_build/
/.vs/
/.vscode/
/tools
test-results
*.userprefs
Expand Down
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"dotnet.preferCSharpExtension": false,
"dotnet.server.useOmnisharp": true,
"dotnet.defaultSolution": "CKAN.sln",
"dotnet.automaticallyCreateSolutionInWorkspace": false,
"dotnet.backgroundAnalysis.analyzerDiagnosticsScope": "fullSolution",
"dotnet.backgroundAnalysis.compilerDiagnosticsScope": "fullSolution",
"omnisharp.useModernNet": false,
"omnisharp.projectLoadTimeout": 600,
"python.defaultInterpreterPath": "py",
"files.watcherExclude": {
"**/_build/**": true
},
"nunitTestRunner.projectsPatterns": [
"_build/out/**/*.Tests.dll"
]
}
32 changes: 4 additions & 28 deletions AutoUpdate/CKAN-autoupdate.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN-AutoUpdateHelper</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
Expand All @@ -16,8 +17,8 @@
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7</LangVersion>
<ApplicationIcon>..\assets\ckan.ico</ApplicationIcon>
<TargetFramework>net45</TargetFramework>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFramework>net48</TargetFramework>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -28,10 +29,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.18" />
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\_build\meta\GlobalAssemblyVersionInfo.cs">
<Link>Properties\GlobalAssemblyVersionInfo.cs</Link>
Expand All @@ -48,25 +45,4 @@
<Exec Command="powershell ../build.ps1 Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Windows_NT'" />
<Exec Command="sh ../build Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Unix'" />
</Target>
<Target Name="ILRepack" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="fr-FR\$(AssemblyName).resources.dll" />
<InputAssemblies Include="it-IT\$(AssemblyName).resources.dll" />
<InputAssemblies Include="pl-PL\$(AssemblyName).resources.dll" />
<InputAssemblies Include="pt-BR\$(AssemblyName).resources.dll" />
<InputAssemblies Include="ru-RU\$(AssemblyName).resources.dll" />
</ItemGroup>
<ILRepack OutputAssembly="AutoUpdater.exe"
MainAssembly="$(AssemblyName).exe"
InputAssemblies="@(InputAssemblies)"
OutputType="$(OutputType)"
WorkingDirectory="$(OutputPath)"
Internalize="true"
Parallel="true" />
<ItemGroup>
<Repacked Include="$(OutputPath)AutoUpdater.*" />
</ItemGroup>
<Copy SourceFiles="@(Repacked)"
DestinationFolder="..\_build\repack\$(Configuration)" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions AutoUpdate/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private static void StartCKAN(string path)
// Start CKAN
if (IsOnMono())
{
Process.Start("mono", String.Format("\"{0}\"", path));
Process.Start("mono", string.Format("\"{0}\"", path));
}
else
{
Expand Down Expand Up @@ -171,7 +171,7 @@ private static bool IsOnWindows()
/// </summary>
/// <param name="sender">Source of unhandled exception</param>
/// <param name="e">Info about the exception</param>
private static void UnhandledExceptionEventHandler(Object sender, UnhandledExceptionEventArgs e)
private static void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
{
ReportError(Properties.Resources.UnhandledException, e.ExceptionObject);
}
Expand Down
7 changes: 3 additions & 4 deletions AutoUpdate/SingleAssemblyResourceManager.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System.IO;
using System.Globalization;
using System.Resources;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;

namespace CKAN.AutoUpdateHelper
{
// Thanks and credit to this guy: https://stackoverflow.com/q/1952638/2422988

class SingleAssemblyResourceManager : ResourceManager
public class SingleAssemblyResourceManager : ResourceManager
{
public SingleAssemblyResourceManager(string basename, Assembly assembly) : base(basename, assembly)
{
Expand All @@ -23,7 +22,7 @@ protected override ResourceSet InternalGetResourceSet(CultureInfo culture,
// Lazy-load default language (without caring about duplicate assignment in race conditions, no harm done)
if (neutralResourcesCulture == null)
{
neutralResourcesCulture = GetNeutralResourcesLanguage(this.MainAssembly);
neutralResourcesCulture = GetNeutralResourcesLanguage(MainAssembly);
}

// If we're asking for the default language, then ask for the
Expand All @@ -34,7 +33,7 @@ protected override ResourceSet InternalGetResourceSet(CultureInfo culture,
}
string resourceFileName = GetResourceFileName(culture);

Stream store = this.MainAssembly.GetManifestResourceStream(resourceFileName);
Stream store = MainAssembly.GetManifestResourceStream(resourceFileName);

// If we found the appropriate resources in the local assembly
if (store != null)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ All notable changes to this project will be documented in this file.
- [Build] Remove log4net, newtonsoft deps from deb package (#3900 by: HebaruSan; reviewed: techman83)
- [GUI] Add test to check GUI thread safety (#3914 by: HebaruSan; reviewed: techman83)
- [Multiple] VSCode clean-up and other minor fixes (#3920 by: HebaruSan)
- [Build] Modernize build system and .NET platform targets (#3929 by: HebaruSan; reviewed: techman83)

## v1.33.2 (Laplace)

Expand Down
1 change: 0 additions & 1 deletion Cmdline/Action/Available.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using System.Collections.Generic;

namespace CKAN.CmdLine
{
Expand Down
13 changes: 5 additions & 8 deletions Cmdline/Action/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public int RunSubCommand(GameInstanceManager mgr, CommonOptions opts, SubCommand
manager = mgr ?? new GameInstanceManager(user);
exitCode = options.Handle(manager, user);
if (exitCode != Exit.OK)
{
return;
}

switch (option)
{
Expand Down Expand Up @@ -214,14 +216,9 @@ private int ShowCacheSizeLimit()
private int SetCacheSizeLimit(SetLimitOptions options)
{
IConfiguration cfg = ServiceLocator.Container.Resolve<IConfiguration>();
if (options.Megabytes < 0)
{
cfg.CacheSizeLimit = null;
}
else
{
cfg.CacheSizeLimit = options.Megabytes * (long)1024 * (long)1024;
}
cfg.CacheSizeLimit = options.Megabytes < 0
? null :
(long?)(options.Megabytes * 1024 * 1024);
return ShowCacheSizeLimit();
}

Expand Down
2 changes: 2 additions & 0 deletions Cmdline/Action/Compat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public int RunSubCommand(GameInstanceManager manager, CommonOptions opts, SubCom
_kspManager = manager ?? new GameInstanceManager(_user);
exitCode = comOpts.Handle(_kspManager, _user);
if (exitCode != Exit.OK)
{
return;
}

switch (option)
{
Expand Down
2 changes: 2 additions & 0 deletions Cmdline/Action/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public int RunSubCommand(GameInstanceManager mgr, CommonOptions opts, SubCommand
manager = mgr ?? new GameInstanceManager(user);
exitCode = options.Handle(manager, user);
if (exitCode != Exit.OK)
{
return;
}

switch (option)
{
Expand Down
6 changes: 4 additions & 2 deletions Cmdline/Action/GameInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ public int RunSubCommand(GameInstanceManager manager, CommonOptions opts, SubCom
Manager = manager ?? new GameInstanceManager(User);
exitCode = options.Handle(Manager, User);
if (exitCode != Exit.OK)
{
return;
}

switch (option)
{
Expand Down Expand Up @@ -461,7 +463,7 @@ private int SetDefaultInstall(DefaultOptions options)
string defaultInstance = Manager.Configuration.AutoStartInstance;
int defaultInstancePresent = 0;

if (!String.IsNullOrWhiteSpace(defaultInstance))
if (!string.IsNullOrWhiteSpace(defaultInstance))
{
defaultInstancePresent = 1;
}
Expand All @@ -477,7 +479,7 @@ private int SetDefaultInstall(DefaultOptions options)
}

// Mark the default instance for the user.
if (!String.IsNullOrWhiteSpace(defaultInstance))
if (!string.IsNullOrWhiteSpace(defaultInstance))
{
keys[0] = Manager.Instances.IndexOfKey(defaultInstance);
}
Expand Down
2 changes: 1 addition & 1 deletion Cmdline/Action/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
ckan_uri = new Uri(ckan_file);
}

string filename = String.Empty;
string filename = string.Empty;

// If it is a local file, we already know the filename. If it is remote, create a temporary file and download the remote resource.
if (ckan_uri.IsFile)
Expand Down
2 changes: 2 additions & 0 deletions Cmdline/Action/Mark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public int RunSubCommand(GameInstanceManager mgr, CommonOptions opts, SubCommand
manager = mgr ?? new GameInstanceManager(user);
exitCode = options.Handle(manager, user);
if (exitCode != Exit.OK)
{
return;
}

switch (option)
{
Expand Down
2 changes: 2 additions & 0 deletions Cmdline/Action/Remove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public int RunCommand(CKAN.GameInstance instance, object raw_options)
foreach (string mod in regMgr.registry.InstalledModules.Select(mod => mod.identifier))
{
if (justins.Any(re => re.IsMatch(mod)))
{
selectedModules.Add(mod);
}
}

// Replace the regular expressions with the selected modules
Expand Down
Loading

0 comments on commit e67b9ee

Please sign in to comment.