Skip to content

Commit

Permalink
Merge pull request #171 from NoxOrg/feature/NOX-703_dotnet8_upgrade
Browse files Browse the repository at this point in the history
NOX-703 Dotnet 8 upgrade
  • Loading branch information
msadikkoseaupa authored Feb 6, 2024
2 parents 47edf14 + 0034cae commit 1c0b101
Show file tree
Hide file tree
Showing 38 changed files with 120 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nox_cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['7.0.x']
dotnet-version: ['8.0.x']
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nox_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['7.0.x']
dotnet-version: ['8.0.x']

steps:
- uses: actions/checkout@v3
Expand Down
12 changes: 12 additions & 0 deletions src/Nox.Cli.Abstractions/Helpers/JsonOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Text.Json;

namespace Nox.Cli.Abstractions.Helpers;

public static class JsonOptions
{
public static JsonSerializerOptions Instance { get; } = new JsonSerializerOptions
{
WriteIndented = false,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
}
8 changes: 4 additions & 4 deletions src/Nox.Cli.Abstractions/Nox.Cli.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Nox.Secrets.Abstractions" Version="7.0.185" />
<PackageReference Include="Spectre.Console.Cli" Version="0.48.0" />
<PackageReference Include="Nox.Secrets" Version="7.0.153" />
<PackageReference Include="Nox.Solution" Version="7.0.161" />
<PackageReference Include="Nox.Solution" Version="7.0.185" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions src/Nox.Cli.Caching/Nox.Cli.Caching.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -14,9 +14,10 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nox.Secrets.Azure" Version="7.0.185" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
<PackageReference Include="YamlDotNet" Version="15.1.1" />
</ItemGroup>

</Project>
18 changes: 6 additions & 12 deletions src/Nox.Cli.Caching/NoxCliCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Nox.Cli.Caching;

public class NoxCliCacheManager: INoxCliCacheManager
{
private INoxCliCache? _cache;
private NoxCliCache? _cache;
private string _cachePath;
private string _cacheFile;
private string _workflowCachePath;
Expand Down Expand Up @@ -299,10 +299,7 @@ internal void GetOnlineWorkflowsAndManifest(IDictionary<string, string> yamlFile
throw new Exception($"GetOnlineWorkflowsAndManifest:-> {onlineFilesJson.ErrorException?.Message}");
}

var onlineFiles = JsonSerializer.Deserialize<List<RemoteFileInfo>>(onlineFilesJson.Content, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
var onlineFiles = JsonSerializer.Deserialize<List<RemoteFileInfo>>(onlineFilesJson.Content, JsonOptions.Instance);

// Read and cache the entries

Expand Down Expand Up @@ -454,7 +451,7 @@ private string[] FindWorkflowsAndManifest(string searchPath = "")
// current or supplied folder
var files = GetFilesWithSearchPatterns(path, searchPatterns, SearchOption.TopDirectoryOnly);

while (!files.Any())
while (files.Length == 0)
{
// root
if (path == null || path.Parent == null)
Expand All @@ -464,15 +461,15 @@ private string[] FindWorkflowsAndManifest(string searchPath = "")
}

// Find special NOX folder
if (Directory.GetDirectories(path.FullName, @".nox").Any())
if (Directory.GetDirectories(path.FullName, @".nox").Length != 0)
{
path = new DirectoryInfo(Path.Combine(path.FullName,".nox"));
files = GetFilesWithSearchPatterns(path, searchPatterns, SearchOption.AllDirectories);
break;
}

// Stop in project root, after checking all sub-directories
if (Directory.GetDirectories(path.FullName, @".git").Any())
if (Directory.GetDirectories(path.FullName, @".git").Length != 0)
{
files = GetFilesWithSearchPatterns(path, searchPatterns, SearchOption.AllDirectories); ;
break;
Expand Down Expand Up @@ -519,10 +516,7 @@ internal void GetOnlineTemplates()

if (onlineFilesJson.StatusCode != HttpStatusCode.OK) return;

var onlineFiles = JsonSerializer.Deserialize<List<RemoteFileInfo>>(onlineFilesJson.Content, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
var onlineFiles = JsonSerializer.Deserialize<List<RemoteFileInfo>>(onlineFilesJson.Content, JsonOptions.Instance);

// Read and cache the entries

Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Cli.Configuration/Nox.Cli.Configuration.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Nox.Cli.Helpers/Nox.Cli.Helpers.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
<PackageReference Include="YamlDotNet" Version="15.1.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.ResourceManager" Version="1.9.0" />
<PackageReference Include="Azure.ResourceManager" Version="1.10.1" />
<PackageReference Include="Azure.ResourceManager.Dns" Version="1.1.0" />
<PackageReference Include="Azure.ResourceManager.KeyVault" Version="1.2.0" />
<PackageReference Include="Azure.ResourceManager.PrivateDns" Version="1.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Abstractions.Extensions;
using Nox.Cli.Abstractions.Helpers;
using Nox.Cli.Plugin.AzDevOps.DTO;
using RestSharp;
using RestSharp.Authenticators;
Expand Down Expand Up @@ -112,7 +113,7 @@ public async Task<IDictionary<string, object>> ProcessAsync(INoxWorkflowContext
Authorized = true
}
};
request.AddJsonBody(JsonSerializer.Serialize(payload, new JsonSerializerOptions{PropertyNamingPolicy = JsonNamingPolicy.CamelCase}));
request.AddJsonBody(JsonSerializer.Serialize(payload, JsonOptions.Instance));
var response = await client.ExecuteAsync<AuthorizeResponse>(request);
if (response.IsSuccessStatusCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Abstractions.Extensions;
using Nox.Cli.Abstractions.Helpers;
using Nox.Cli.Plugin.AzDevOps.DTO;
using RestSharp;

Expand Down Expand Up @@ -118,7 +119,7 @@ public async Task<IDictionary<string, object>> ProcessAsync(INoxWorkflowContext
}
}
};
request.AddJsonBody(JsonSerializer.Serialize(payload, new JsonSerializerOptions{PropertyNamingPolicy = JsonNamingPolicy.CamelCase}));
request.AddJsonBody(JsonSerializer.Serialize(payload, JsonOptions.Instance));
var response = await client.ExecuteAsync<AuthorizeResponse>(request);
if (response.IsSuccessStatusCode)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Microsoft.Graph" Version="5.39.0" />
<PackageReference Include="Microsoft.Graph" Version="5.41.0" />
<PackageReference Include="RestSharp" Version="110.2.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions;
using Nox.Cli.Abstractions.Exceptions;
using Nox.Cli.Abstractions.Extensions;
using Nox.Cli.Helpers;
using Nox.Cli.Plugin.Console.JsonSchema;
using RestSharp;
using Spectre.Console;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using Nox.Cli.Abstractions.Helpers;

namespace Nox.Cli.Plugin.Console;

Expand Down Expand Up @@ -97,7 +97,7 @@ public NoxActionMetaData Discover()

private string? _schema = null!;

private IDictionary<string, string?>? _schemaCache;
private Dictionary<string, string?>? _schemaCache;

private string[]? _includedPrompts;

Expand Down Expand Up @@ -182,13 +182,8 @@ public async Task<IDictionary<string, object>> ProcessAsync(INoxWorkflowContext

if (json != null)
{
var serializeOptions = new JsonSerializerOptions
{
WriteIndented = false,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

var jsonSchemaRaw = JsonSerializer.Deserialize<JsonSchema.JsonSchemaRaw>(json, serializeOptions);

var jsonSchemaRaw = JsonSerializer.Deserialize<JsonSchema.JsonSchemaRaw>(json, JsonOptions.Instance);

if (jsonSchemaRaw != null)
{
Expand Down Expand Up @@ -455,19 +450,19 @@ private void PromptBoolean(string prompt, string rootKey, string key, string yam
_yaml.AppendLine($"{yamlPrefix}{key}: {response.ToString().ToLower()}");
_responses[newKey] = response;
}

private void PromptInteger(string prompt, string rootKey, string key, string yamlPrefix, bool isRequired)
{
var newKey = $"{rootKey}.{key}".TrimStart('.');
var spectrePrompt = new TextPrompt<int>(prompt)
.PromptStyle(Style.Parse("seagreen1"))
.DefaultValueStyle(Style.Parse("mediumpurple3_1"));

if (!isRequired)
{
spectrePrompt.AllowEmpty();
}


var defaultValue = GetDefault<int>(newKey);

Expand Down Expand Up @@ -514,14 +509,14 @@ private void PromptEnum(string prompt, string rootKey, string key, string yamlPr
.Title(prompt)
.HighlightStyle(Style.Parse("mediumpurple3_1"))
.AddChoices(enumList.ToArray());

var response = AnsiConsole.Prompt(spectrePrompt);

_responses[newKey] = response;
_yaml.AppendLine($"{yamlPrefix}{key}: {response}");
AnsiConsole.MarkupLine($"{prompt} [seagreen1]{_responses[newKey]}[/]");
}

private void PromptMultipleEnum(string prompt, string rootKey, string key, string yamlPrefix, List<string> enumList)
{
var newKey = $"{rootKey}.{key}".TrimStart('.');
Expand All @@ -530,11 +525,11 @@ private void PromptMultipleEnum(string prompt, string rootKey, string key, strin
.Title(prompt)
.HighlightStyle(Style.Parse("mediumpurple3_1"))
.AddChoices(enumList.ToArray())

);

var responseValue = String.Join(',', response);
_responses[newKey] = responseValue;
_responses[newKey] = responseValue;
_yaml.AppendLine($"{yamlPrefix}{key}: [{responseValue}]");
AnsiConsole.MarkupLine($"{prompt} [seagreen1]{_responses[newKey]}[/]");
}
Expand All @@ -543,11 +538,11 @@ private void AppendKey(string yamlSpacing, string key)
{
if (!string.IsNullOrWhiteSpace(key))
{
_yaml.AppendLine($"{yamlSpacing}{key}:");
_yaml.AppendLine($"{yamlSpacing}{key}:");
}
}


private T? GetDefault<T>(string key)
{
if (_defaults?.ContainsKey(key) ?? false)
Expand All @@ -561,7 +556,7 @@ private void AppendKey(string yamlSpacing, string key)
private void ProcessDefaults(string key, string yamlSpacing, string yamlSpacingPostfix)
{
Regex defaultArrayRegex = new(@"\[(.*?)\]\.(.*)", RegexOptions.Compiled | RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));

_yaml.AppendLine($"{yamlSpacing}{key}:");
var arrayIndex = -1;
foreach (var defaultItem in _defaults!.Where(d => d.Key.StartsWith(key, StringComparison.CurrentCultureIgnoreCase)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 1c0b101

Please sign in to comment.