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

Upgraded to .Net 8.0 #658

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ dotnet_diagnostic.IDE0090.severity = warning # expression can be simplified
dotnet_diagnostic.IDE0130.severity = none # Namespace does not match folder structure
dotnet_diagnostic.IDE0161.severity = error # Namespace declaration preferences
dotnet_diagnostic.IDE0210.severity = none # Convert to top-level statements
dotnet_diagnostic.IDE0290.severity = suggestion # Use primary constructor
dotnet_diagnostic.IDE0300.severity = suggestion # Collection initialization can be simplified
dotnet_diagnostic.IDE0301.severity = suggestion # Collection initialization can be simplified
dotnet_diagnostic.IDE0305.severity = suggestion # Collection initialization can be simplified
dotnet_diagnostic.IDE1006.severity = none # These words must begin with upper case characters


Expand Down
5 changes: 1 addition & 4 deletions src/PAModel/Serializers/MsAppSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ private static string AsString(ZipArchiveEntry entry)

public static CanvasDocument Load(Stream streamToMsapp, ErrorContainer errors)
{
if (streamToMsapp == null)
{
throw new ArgumentNullException(nameof(streamToMsapp));
}
ArgumentNullException.ThrowIfNull(streamToMsapp);

// Read raw files.
// Apply transforms.
Expand Down
4 changes: 2 additions & 2 deletions src/PAModel/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
"net7.0": {
"net8.0": {
"Newtonsoft.Json": {
"type": "Direct",
"requested": "[13.0.1, )",
Expand Down Expand Up @@ -119,4 +119,4 @@
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/Persistence.Tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[*.cs]

# Rule overrides:
dotnet_diagnostic.CA1861.severity = silent # Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
dotnet_diagnostic.CA1859.severity = silent # Change return type of method
14 changes: 0 additions & 14 deletions src/Persistence.Tests/PersistenceLibraryExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ public void MessageTest()
.WithMessage("[5000:MsappArchiveError] An error was detected in an msapp file. A test reason2. Line: 5; Column: 3; MsappEntry: src/entry1.txt; JsonPath: some.json.path[0].value;");
}

[TestMethod]
public void IsSerializableTests()
{
new PersistenceLibraryException(PersistenceErrorCode.DeserializationError).Should().BeBinarySerializable();
new PersistenceLibraryException(PersistenceErrorCode.SerializationError, "A test reason.").Should().BeBinarySerializable();
new PersistenceLibraryException(PersistenceErrorCode.MsappArchiveError, "A test reason2.")
{
MsappEntryFullPath = "src/entry1.txt",
LineNumber = 5,
Column = 3,
JsonPath = "some.json.path[0].value",
}.Should().BeBinarySerializable();
}

/// <summary>
/// Throws the specified exception and then asserts it was thrown,
/// returning the <see cref="ExceptionAssertions{TException}"/> allowing caller to
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence.Tests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public TestBase()
ControlFactory = ServiceProvider.GetRequiredService<IControlFactory>();
}

private static IServiceProvider BuildServiceProvider()
private static ServiceProvider BuildServiceProvider()
{
var serviceCollection = new ServiceCollection();
var serviceProvider = ConfigureServices(serviceCollection);

return serviceProvider;
}

private static IServiceProvider ConfigureServices(IServiceCollection services)
private static ServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddPowerAppsPersistence(useDefaultTemplates: true);

Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static string FirstCharToUpper(this string input)

var first = char.ToUpper(input[0], CultureInfo.InvariantCulture);
var rest = input.AsSpan(1);
return string.Concat(new ReadOnlySpan<char>(first), rest);
return string.Concat(new ReadOnlySpan<char>(in first), rest);
}

public static bool StartsWithInvariant(this string input, string value)
Expand Down
26 changes: 0 additions & 26 deletions src/Persistence/PersistenceLibraryException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using System.Globalization;
using System.Runtime.Serialization;
using System.Text;
using YamlDotNet.Core;

Expand Down Expand Up @@ -32,20 +31,6 @@ public PersistenceLibraryException(PersistenceErrorCode errorCode, string? reaso
ErrorCode = errorCode.CheckArgumentInRange();
}

protected PersistenceLibraryException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
ErrorCode = ((PersistenceErrorCode)info.GetInt32(nameof(ErrorCode))).CheckArgumentInRange();
MsappEntryFullPath = info.GetString(nameof(MsappEntryFullPath));
JsonPath = info.GetString(nameof(JsonPath));

// Normalize null numbers to make serialization easier. -1 isn't valid values for LineNumber or Column.
var lineNumber = info.GetInt64(nameof(LineNumber));
LineNumber = lineNumber < 0 ? null : lineNumber;
var column = info.GetInt64(nameof(Column));
Column = column < 0 ? null : column;
}

public override string Message => ComposeMessage();

public string? Reason => base.Message.Length == 0 ? null : base.Message; // we get the storage of a string for free
Expand Down Expand Up @@ -103,17 +88,6 @@ private string ComposeMessage()
return sb.ToString();
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(nameof(ErrorCode), ErrorCode);
info.AddValue(nameof(MsappEntryFullPath), MsappEntryFullPath);
info.AddValue(nameof(JsonPath), JsonPath);
info.AddValue(nameof(LineNumber), LineNumber ?? -1);
info.AddValue(nameof(Column), Column ?? -1);

base.GetObjectData(info, context);
}

internal static PersistenceLibraryException FromYamlException(YamlException ex, PersistenceErrorCode errorCode)
{
return ex.Start.Equals(Mark.Empty)
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/Yaml/ControlObjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.Yaml;

public class ControlObjectFactory : IObjectFactory
{
private readonly IObjectFactory _defaultObjectFactory;
private readonly DefaultObjectFactory _defaultObjectFactory;
private readonly IControlTemplateStore _controlTemplateStore;
private readonly IControlFactory _controlFactory;

Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/Yaml/FirstClassControlsEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.Yaml;
internal sealed class FirstClassControlsEmitter : ChainedEventEmitter
{
private readonly IControlTemplateStore _controlTemplateStore;
private readonly IReadOnlySet<string> _shortNameTypes = new HashSet<string> { "App", "Host", "Screen" };
private readonly HashSet<string> _shortNameTypes = new() { "App", "Host", "Screen" };

public FirstClassControlsEmitter(IEventEmitter nextEmitter, IControlTemplateStore controlTemplateStore)
: base(nextEmitter)
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
"net7.0": {
"net8.0": {
"Microsoft.Extensions.Logging": {
"type": "Direct",
"requested": "[7.0.0, )",
Expand Down
2 changes: 1 addition & 1 deletion src/Versions.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFrameworkVersion>net7.0</TargetFrameworkVersion>
<TargetFrameworkVersion>net8.0</TargetFrameworkVersion>
<YamlDotNetVersion>15.1.2</YamlDotNetVersion>
<MicrosoftNETTestSdkVersion>17.7.1</MicrosoftNETTestSdkVersion>
<MSTestTestAdapterVersion>3.2.2</MSTestTestAdapterVersion>
Expand Down
Loading