Skip to content

Commit

Permalink
Merge pull request #3 from RTUITLab/develop
Browse files Browse the repository at this point in the history
v5.0
  • Loading branch information
CAPCHIK authored May 6, 2024
2 parents eec17da + cf8853c commit f0548cc
Show file tree
Hide file tree
Showing 23 changed files with 481 additions and 335 deletions.
5 changes: 3 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"isRoot": true,
"tools": {
"nuke.globaltool": {
"version": "5.0.2",
"version": "8.0.0",
"commands": [
"nuke"
]
],
"rollForward": false
}
}
}
82 changes: 82 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,85 @@ dotnet_analyzer_diagnostic.category-Globalization.severity = suggestion

# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = suggestion
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
1 change: 0 additions & 1 deletion .nuke

This file was deleted.

115 changes: 115 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
"items": {
"type": "string"
}
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
},
"Runtime": {
"type": "string"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Publish",
"Restore"
]
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Publish",
"Restore"
]
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
}
}
}
}
}
4 changes: 4 additions & 0 deletions .nuke/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./build.schema.json",
"Solution": "Excursion360.Desktop.sln"
}
62 changes: 28 additions & 34 deletions Excursion360.Desktop/ConsoleHelper.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Excursion360.Desktop;

namespace Excursion360.Desktop
public static class ConsoleHelper
{
public static class ConsoleHelper
public static int SelectOneFromArray(string headerLine, string[] values)
{
public static int SelectOneFromArray(string headerLine, string[] values)
values = values ?? throw new ArgumentNullException(nameof(values));
var index = 0;
while (true)
{
values = values ?? throw new ArgumentNullException(nameof(values));
var index = 0;
while (true)
Console.Clear();
Console.WriteLine(headerLine);
for (int i = 0; i < values.Length; i++)
{
Console.Clear();
Console.WriteLine(headerLine);
for (int i = 0; i < values.Length; i++)
{
Console.BackgroundColor = index == i ? ConsoleColor.White : ConsoleColor.Black;
Console.ForegroundColor = index == i ? ConsoleColor.Black : ConsoleColor.White;
Console.WriteLine(values[i]);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
var key = Console.ReadKey();
switch (key.Key)
{
case ConsoleKey.UpArrow:
index = index <= 0 ? 0 : index - 1;
break;
case ConsoleKey.DownArrow:
index = index + 1 >= values.Length ? values.Length - 1 : index + 1;
break;
case ConsoleKey.Enter:
return index;
default:
break;
}
Console.BackgroundColor = index == i ? ConsoleColor.White : ConsoleColor.Black;
Console.ForegroundColor = index == i ? ConsoleColor.Black : ConsoleColor.White;
Console.WriteLine(values[i]);
}
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
var key = Console.ReadKey();
switch (key.Key)
{
case ConsoleKey.UpArrow:
index = index <= 0 ? 0 : index - 1;
break;
case ConsoleKey.DownArrow:
index = index + 1 >= values.Length ? values.Length - 1 : index + 1;
break;
case ConsoleKey.Enter:
return index;
default:
break;
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions Excursion360.Desktop/Excursion360.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,13 +22,13 @@

<ItemGroup>

<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="MintPlayer.PlatformBrowser" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="MintPlayer.PlatformBrowser" Version="8.0.0" />
</ItemGroup>

</Project>
52 changes: 17 additions & 35 deletions Excursion360.Desktop/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using System.Linq;
using Microsoft.AspNetCore.Http.Features;

namespace Excursion360.Desktop
namespace Excursion360.Desktop;

static class Extensions
{
static class Extensions
public static ILogger CreateLogger(this IWebHost host, string categoryName)
=> host.Services.GetRequiredService<ILoggerFactory>().CreateLogger(categoryName);
public static Uri GetListeningUri(this IHost host)
{
public static ILogger CreateLogger(this IWebHost host, string categoryName)
{
return host.Services.GetService<ILoggerFactory>().CreateLogger(categoryName);
}
public static Uri GetListeningUri(this IHost host)
{
return new Uri(host.Services
.GetRequiredService<IServer>()
.Features
.Get<IServerAddressesFeature>()
.Addresses
.Single(a => a.StartsWith("http:", StringComparison.Ordinal)));
}
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (seenKeys.Add(keySelector(element)))
{
yield return element;
}
}
}
return new Uri(host.Services
.GetRequiredService<IServer>()
.Features
.GetRequiredFeature<IServerAddressesFeature>()
.Addresses
.Single(a => a.StartsWith("http:", StringComparison.Ordinal)));
}

public static string ExcursionDirectoryPath(this IConfiguration configuration)
=> configuration.GetValue<string?>("excursionsPath", null) ?? Directory.GetCurrentDirectory();
}
Loading

0 comments on commit f0548cc

Please # to comment.