Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DI-1337] Data Import 2.3 .NET 8 Update #62

Merged
merged 16 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/on-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Publish .NET Assemblies
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/on-pullrequest-or-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- ".github/**/*.yml"
workflow_dispatch:

env:
env:
DB_PASS: ${{ secrets.DB_PASS }}

jobs:
Expand All @@ -49,7 +49,7 @@ jobs:
ACCEPT_EULA: 'Y'
ports:
- 1433:1433

defaults:
run:
shell: pwsh
Expand All @@ -60,15 +60,15 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # v3.0.3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Build
run: ./build.ps1 -Command Build -Configuration Release

- name: Run Unit Tests
if: success()
run: ./build.ps1 -Command UnitTest -Configuration Release -Report True

- name: Integration Tests
run: ./build.ps1 -Command IntegrationTest -Configuration Release -Report True
shell: pwsh
Expand Down
28 changes: 15 additions & 13 deletions DataImport.Common.Tests/DataImport.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn),1573,1591,1712</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataImport.Common\DataImport.Common.csproj" />
<ProjectReference Include="..\DataImport.Models\DataImport.Models.csproj" />
<ProjectReference Include="..\DataImport.TestHelpers\DataImport.TestHelpers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="7.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.2.0">
<PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.8.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.1" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit.Console" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.41.0.50478">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit.Console" Version="3.17.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.23.1.88495">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -44,4 +46,4 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
</Project>
6 changes: 3 additions & 3 deletions DataImport.Common.Tests/LogLevelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ public void ShouldReturnLogLevelsFiltered()
List<string> actual = LogLevelConstants.GetValidList(LogLevelConstants.Error);
Console.WriteLine($"Expected: {string.Join(",", expected)}");
Console.WriteLine($"Actual: {string.Join(",", actual)}");
Assert.IsTrue(actual.SequenceEqual(expected));
Assert.That(actual.SequenceEqual(expected), Is.True);
}

[Test]
public void ShouldReturnLogLevelsIfFilterIsEmpty()
{
List<string> expected = LogLevelConstants.All.ToList();
List<string> actual = LogLevelConstants.GetValidList("");
Assert.IsTrue(actual.SequenceEqual(expected));
Assert.That(actual.SequenceEqual(expected), Is.True);
}

[Test]
public void ShouldReturnLogLevelsIfFilterIsNotFound()
{
List<string> expected = LogLevelConstants.All.ToList();
List<string> actual = LogLevelConstants.GetValidList("Test");
Assert.IsTrue(actual.SequenceEqual(expected));
Assert.That(actual.SequenceEqual(expected), Is.True);
}
}
}
4 changes: 2 additions & 2 deletions DataImport.Common.Tests/PowerShellPreprocessorServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void ShouldReturnInputStreamWhenScriptIsNullOrEmpty(string scriptContent)

output.ShouldBe(input);

Assert.AreSame(input, output);
Assert.That(input, Is.SameAs(output));
}

[Test]
Expand Down Expand Up @@ -391,7 +391,7 @@ public void ShouldProvideConvertFromFixedWidthCmdlet()
var output = _service.ProcessStreamWithScript(scriptContent, input);
var actual = new StreamReader(output).ReadToEnd();

Assert.AreEqual(expected, actual, message);
Assert.That(expected, Is.EqualTo(actual), message);
};

test("Write-Output (ConvertFrom-FixedWidth -FixedWidthString \"012 45 789\" -FieldMap @(0, 4, 7) -NoTrim)",
Expand Down
6 changes: 3 additions & 3 deletions DataImport.Common/AzureFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task Upload(string fileName, Stream fileStream, Agent agent)
var recordCount = fileStream.TotalLines(fileName.IsCsvFile());

_fileHelper.LogFile(fileName, agent.Id, cloudFile.StorageUri.PrimaryUri.ToString(), FileStatus.Uploaded, recordCount);
_logger.LogInformation("File '{file}' was uploaded to '{uri}' for Agent '{name}' (Id: {id}).", fileName, cloudFile.StorageUri.PrimaryUri, agent.Name, agent.Id);
_logger.LogInformation("File '{File}' was uploaded to '{Uri}' for Agent '{Name}' (Id: {Id}).", fileName, cloudFile.StorageUri.PrimaryUri, agent.Name, agent.Id);
}
else
{
Expand Down Expand Up @@ -84,11 +84,11 @@ public async Task Transfer(Stream stream, string file, Agent agent)
var recordCount = stream.TotalLines(file.IsCsvFile());

await _fileHelper.LogFileAsync(shortFileName, agent.Id, cloudFile.StorageUri.PrimaryUri.ToString(), FileStatus.Uploaded, recordCount);
_logger.LogInformation("Successfully transferred file {file} to {uri} by agent ID: {agent}", shortFileName, cloudFile.StorageUri.PrimaryUri, agent.Id);
_logger.LogInformation("Successfully transferred file {File} to {Uri} by agent ID: {Agent}", shortFileName, cloudFile.StorageUri.PrimaryUri, agent.Id);
}
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error in TransferFile for file: {file} on site: ", agent.Url);
_logger.LogError(ex, "Unexpected error in TransferFile for file: {File} on site: ", agent.Url);
await _fileHelper.LogFileAsync(shortFileName, agent.Id, "", FileStatus.ErrorUploaded, 0);
}
}
Expand Down
29 changes: 20 additions & 9 deletions DataImport.Common/DataImport.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,44 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<!--
Make sure any documentation comments which are included in code get checked for syntax during the build, but do
not report warnings for missing comments.
CS1573: Parameter 'parameter' has no matching param tag in the XML comment for 'parameter' (but other parameters do)
CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
CS1712: Type parameter 'type_parameter' has no matching typeparam tag in the XML comment on 'type_or_member' (but other type parameters do)
-->
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn),1573,1591,1712</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataImport.Models\DataImport.Models.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.2.0">
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.8.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.1" />
<PackageReference Include="Microsoft.Azure.KeyVault.Core" Version="3.0.5" />
<PackageReference Include="Microsoft.Data.Services.Client" Version="5.8.4" />
<PackageReference Include="Microsoft.Data.Services.Client" Version="5.8.5" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.41.0.50478">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.23.1.88495">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="RestSharp" Version="106.15.0" />
<PackageReference Include="CsvHelper" Version="27.2.1" />
<PackageReference Include="CsvHelper" Version="31.0.3" />
<PackageReference Include="Rijndael256" Version="3.2.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions DataImport.Common/ExtensionMethods/FileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
using Microsoft.Extensions.Options;
using System;
using System.IO;
using System.Linq;

namespace DataImport.Common.ExtensionMethods
{
public static class FileExtensions
{
private static IOptions<ConnectionStrings> ConnectionStringsOptions => _connectionStringsOptions;
private static IOptions<ConnectionStrings> _connectionStringsOptions;

public static void SetConnectionStringsOptions(IOptions<ConnectionStrings> options)
Expand Down Expand Up @@ -53,7 +51,7 @@ private static bool IsEmptyRecord(string s)
{
if (string.IsNullOrWhiteSpace(s)) return true;
var array = s.Split(',');
return array.All(x => String.IsNullOrWhiteSpace(x));
return Array.TrueForAll(array, x => String.IsNullOrWhiteSpace(x));
}

public static bool IsCsvFile(this string fileName) =>
Expand Down
2 changes: 1 addition & 1 deletion DataImport.Common/Helpers/EnumHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static string GetEnumDescription(Enum value)

if (attributes != null && attributes.Any())
{
return attributes.First().Description;
return attributes[0].Description;
}

return value.ToString();
Expand Down
7 changes: 4 additions & 3 deletions DataImport.Common/HttpContextHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ namespace Microsoft.AspNetCore.Http
/// </summary>
internal static class HttpContextHelper
{
#pragma warning disable IDE0055
private static readonly HttpContextAccessor _httpContextAccessor = new HttpContextAccessor();

#pragma warning restore IDE0055
/// <summary>
/// Gets the current <see cref="HttpContext"/>. Returns <c>null</c> if there is no current <see cref="HttpContext"/>.
/// </summary>
#if NET5_0_OR_GREATER
#pragma warning disable S1133 // Deprecated code should be removed
[Obsolete("Prefer accessing HttpContext via injection", error: false, DiagnosticId = "HttpContextCurrent", UrlFormat = "https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context")]
#endif
#pragma warning restore S1133 // Deprecated code should be removed
public static HttpContext Current => _httpContextAccessor.HttpContext;
}
}
6 changes: 3 additions & 3 deletions DataImport.Common/LocalFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task Upload(string fileName, Stream fileStream, Agent agent)

_fileHelper.LogFile(fileName, agent.Id, UrlUtility.ConvertLocalPathToUri(fullFilePath), FileStatus.Uploaded, recordCount);

_logger.LogInformation("File '{file}' was uploaded to '{path}' for Agent '{name}' (Id: {id}).", fileName, uploadPath, agent.Name, agent.Id);
_logger.LogInformation("File '{File}' was uploaded to '{Path}' for Agent '{Name}' (Id: {Id}).", fileName, uploadPath, agent.Name, agent.Id);
}

public virtual async Task Transfer(Stream stream, string file, Agent agent)
Expand All @@ -73,11 +73,11 @@ public virtual async Task Transfer(Stream stream, string file, Agent agent)
var recordCount = stream.TotalLines(file.IsCsvFile());

await _fileHelper.LogFileAsync(shortFileName, agent.Id, localFileUri.AbsoluteUri, FileStatus.Uploaded, recordCount);
_logger.LogInformation("Successfully transferred file {file} to {path} by agent ID: {id}", shortFileName, localFileUri.AbsoluteUri, agent.Id);
_logger.LogInformation("Successfully transferred file {File} to {Path} by agent ID: {Id}", shortFileName, localFileUri.AbsoluteUri, agent.Id);
}
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error in TransferFile for file: {file} on site: {path}", file, agent.Url);
_logger.LogError(ex, "Unexpected error in TransferFile for file: {File} on site: {Path}", file, agent.Url);
await _fileHelper.LogFileAsync(shortFileName, agent.Id, "", FileStatus.ErrorUploaded, 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ public ExternalPreprocessorException(string message)
public ExternalPreprocessorException(string message, params Exception[] innerExceptions)
: base(message, innerExceptions) { }

#pragma warning disable S1133 // Deprecated code should be removed
[Obsolete("Obsolete for NET 8", DiagnosticId = "SYSLIB0051")]
protected ExternalPreprocessorException(SerializationInfo info, StreamingContext context)
: base(info, context) { }

[Obsolete("Obsolete for NET 8", DiagnosticId = "SYSLIB0051")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(ProcessName), ProcessName);
info.AddValue(nameof(Errors), Errors);
}
#pragma warning disable S1133 // Deprecated code should be removed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ public PowerShellProcessException(string message)

public PowerShellProcessException(string message, params Exception[] innerExceptions)
: base(message, innerExceptions) { }

#pragma warning disable S1133 // Deprecated code should be removed
[Obsolete("Obsolete for NET 8", DiagnosticId = "SYSLIB0051")]
protected PowerShellProcessException(SerializationInfo info, StreamingContext context)
: base(info, context) { }

[Obsolete("Obsolete for NET 8", DiagnosticId = "SYSLIB0051")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(Errors), Errors);
}
#pragma warning disable S1133 // Deprecated code should be removed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ public PowerShellValidateException(ParseError[] parseErrors)
public PowerShellValidateException(string message)
: base(message) { }

#pragma warning disable S1133 // Deprecated code should be removed
[Obsolete("Obsolete for NET 8", DiagnosticId = "SYSLIB0051")]
protected PowerShellValidateException(SerializationInfo info, StreamingContext context)
: base(info, context) { }

[Obsolete("Obsolete for NET 8", DiagnosticId = "SYSLIB0051")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(ParseErrors), ParseErrors);
}
#pragma warning disable S1133 // Deprecated code should be removed
}
}
12 changes: 6 additions & 6 deletions DataImport.EdFi.UnitTests/DataImport.EdFi.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataImport.EdFi\DataImport.EdFi.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="7.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="FakeItEasy" Version="8.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions DataImport.EdFi/DataImport.EdFi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DataImport.Common\DataImport.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper" Version="13.0.1" />
</ItemGroup>
</Project>
Loading
Loading