Skip to content

Commit

Permalink
Apply dotnet format and fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Aug 15, 2024
1 parent 2e685ac commit 2176b76
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Notify;
using OrchardCore.Media.Models;
using OrchardCore.Media.Processing;
using OrchardCore.Media.Services;
using OrchardCore.Media.ViewModels;
using OrchardCore.Navigation;
using OrchardCore.Routing;
using Format = OrchardCore.Media.Processing.Format;
using ResizeMode = OrchardCore.Media.Processing.ResizeMode;

namespace OrchardCore.Media.Controllers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
public static class MediaOrchardHelperExtensions
#pragma warning restore CA1050 // Declare types in namespaces
{
private static readonly HashSet<string> _imageExtensions = new(StringComparer.OrdinalIgnoreCase) { ".bmp", ".gif", ".jpeg", ".jpg", ".png", ".webp" };
private static readonly HashSet<string> _imageExtensions = new(StringComparer.OrdinalIgnoreCase)
{
".bmp",
".gif",
".jpeg",
".jpg",
".png",
".webp"
};

/// <summary>
/// Determines if a path is an image file.
Expand All @@ -17,6 +25,6 @@ public static class MediaOrchardHelperExtensions
/// <returns>true if the path is an image file. Otherwise false.</returns>
public static bool IsImageFile(this IOrchardHelper _, string path)
{
return _imageExtensions.Contains(System.IO.Path.GetExtension(path));
return _imageExtensions.Contains(Path.GetExtension(path));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using OrchardCore.Data.Documents;
using OrchardCore.Media.Processing;

namespace OrchardCore.Media.Models;

Expand All @@ -13,8 +12,8 @@ public class MediaProfile
public string Hint { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public ResizeMode Mode { get; set; }
public Format Format { get; set; }
public Processing.ResizeMode Mode { get; set; }
public Processing.Format Format { get; set; }
public int Quality { get; set; }
public string BackgroundColor { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using OrchardCore.Media.Fields;
using OrchardCore.Media.Processing;
using OrchardCore.Media.Services;
using Format = OrchardCore.Media.Processing.Format;
using ResizeMode = OrchardCore.Media.Processing.ResizeMode;

#pragma warning disable CA1050 // Declare types in namespaces
public static class OrchardRazorHelperExtensions
Expand All @@ -14,7 +16,7 @@ public static class OrchardRazorHelperExtensions
/// <summary>
/// Returns the relative URL of the specified asset path with optional resizing parameters.
/// </summary>
public static string AssetUrl(this IOrchardHelper orchardHelper, string assetPath, int? width = null, int? height = null, ResizeMode resizeMode = ResizeMode.Undefined, bool appendVersion = false, int? quality = null, Format format = Format.Undefined, Anchor anchor = null, string bgcolor = null)
public static string AssetUrl(this IOrchardHelper orchardHelper, string assetPath, int? width = null, int? height = null, ResizeMode resizeMode = ResizeMode.Undefined, bool appendVersion = false, int? quality = null, Format format = Format.Undefined, Anchor anchor = null, string bgColor = null)
{
var mediaFileStore = orchardHelper.HttpContext.RequestServices.GetService<IMediaFileStore>();

Expand All @@ -32,7 +34,7 @@ public static string AssetUrl(this IOrchardHelper orchardHelper, string assetPat
resolvedAssetPath = fileVersionProvider.AddFileVersionToPath(orchardHelper.HttpContext.Request.PathBase, resolvedAssetPath);
}

return orchardHelper.ImageResizeUrl(resolvedAssetPath, width, height, resizeMode, quality, format, anchor, bgcolor);
return orchardHelper.ImageResizeUrl(resolvedAssetPath, width, height, resizeMode, quality, format, anchor, bgColor);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OrchardCore.Media.Processing;
using Format = OrchardCore.Media.Processing.Format;
using ResizeMode = OrchardCore.Media.Processing.ResizeMode;

namespace OrchardCore.Media.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using OrchardCore.Media.Fields;
using OrchardCore.Media.Processing;
using OrchardCore.Media.Services;
using Format = OrchardCore.Media.Processing.Format;
using ResizeMode = OrchardCore.Media.Processing.ResizeMode;

namespace OrchardCore.Media.TagHelpers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using OrchardCore.Media.Processing;

namespace OrchardCore.Media.ViewModels;

Expand All @@ -13,8 +12,8 @@ public class MediaProfileViewModel
public int CustomWidth { get; set; }
public int SelectedHeight { get; set; }
public int CustomHeight { get; set; }
public ResizeMode SelectedMode { get; set; }
public Format SelectedFormat { get; set; }
public Processing.ResizeMode SelectedMode { get; set; }
public Processing.Format SelectedFormat { get; set; }
public int Quality { get; set; } = 100;
public string BackgroundColor { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, Jso

if (!reader.TryGetDateTime(out var value))
{
var stringValue = reader.GetString();
var stringValue = reader.GetString();
if (DateTime.TryParse(stringValue, out value))
{
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ZoneTag
public static async ValueTask<Completion> WriteToAsync(
IReadOnlyList<FilterArgument> argumentsList,
IReadOnlyList<Statement> statements,
TextWriter _,
TextWriter _,
TextEncoder encoder,
TemplateContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
using System.ComponentModel;
using System.Linq;
using System.Reflection;

namespace OrchardCore.Modules.Manifest;

using Xunit;
using Xunit.Abstractions;
using static BindingFlags;

namespace OrchardCore.Modules.Manifest;
// TODO: TBD: now to test I want to look at actually doing this in a demo-assembly if possible...
// TODO: TBD: which will be a bit tricky considering ModuleAttribute can appear exactly once...
// TODO: TBD: testing via the CSPROJ aspect... i.e. to load the assembly in reference and check that it 'works' ...
Expand Down Expand Up @@ -78,7 +75,7 @@ public abstract class FeatureAttributeTests<TAttribute>
/// <summary>
/// Public|Instance
/// </summary>
private const BindingFlags CtorFlags = Public | Instance;
private const BindingFlags CtorFlags = BindingFlags.Public | BindingFlags.Instance;

/// <summary>
/// Creates a <typeparamref name="TAttribute"/> from its <paramref name="args"/>, with
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Linq;

namespace OrchardCore.Modules.Manifest;

using Xunit;
using Xunit.Abstractions;

namespace OrchardCore.Modules.Manifest;
/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Reflection;

namespace OrchardCore.Modules.Manifest;

using Xunit;
using Xunit.Abstractions;

namespace OrchardCore.Modules.Manifest;
/// <inheritdoc/>
public abstract class ModuleAttributeTests<TAttribute> : FeatureAttributeTests<TAttribute>
where TAttribute : ModuleAttribute
Expand Down Expand Up @@ -83,7 +81,6 @@ protected virtual void VerifyDefault(TAttribute module, string type)
Assert.Equal(type, module.Type);
}

#pragma warning disable xUnit1013 // Public method on test class should be marked as a Theory
#pragma warning disable xUnit1003 // Test data fulfilled by derived tests
/// <summary>
/// Verifies that the Default instance values, etc, are appropriate.
Expand All @@ -93,8 +90,6 @@ protected virtual void VerifyDefault(TAttribute module, string type)
[Theory]
public virtual void Default(string type) => VerifyDefault(CreateFromArgs(classifier: null), type);
#pragma warning restore xUnit1003
#pragma warning restore xUnit1013

/// <summary>
/// Verifies the <paramref name="expected"/> <see cref="Version"/>, including
/// <paramref name="fieldCount"/> aligned with the <em>OrchardCore</em> usage. Note
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Linq;

namespace OrchardCore.Modules.Manifest;

using DisplayManagement.Manifest;
using OrchardCore.DisplayManagement.Manifest;
using Xunit;
using Xunit.Abstractions;

namespace OrchardCore.Modules.Manifest;
// TODO: TBD: add tests that help us expose non-named ctor args...
// TODO: TBD: i.e. avoid ambiguous args...
/// <inheritdoc/>
Expand Down Expand Up @@ -41,7 +39,7 @@ public class TestAttributePrefix : Attribute { }
#pragma warning restore CA1018

// TODO: MWP: could probably separate this between classes, Theory at one level, InlineData at another...
// TODO: MWP: plus separate out DisplayManagement tests to its own assembly, potentialy...
// TODO: MWP: plus separate out DisplayManagement tests to its own assembly, potentially...
/// <summary>
/// Verify a couple of scenarios parsing an Attribute Prefix.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// TODO: MWP: rinse and repeat for module marker ...
using System;
using System.Linq;

namespace OrchardCore.DisplayManagement.Manifest;

using Modules.Manifest;
using OrchardCore.Modules.Manifest;
using Xunit;
using Xunit.Abstractions;

namespace OrchardCore.DisplayManagement.Manifest;
/// <inheritdoc/>
public class ThemeAttributeTests : ModuleAttributeTests<ThemeAttribute>
{
Expand Down
20 changes: 10 additions & 10 deletions test/OrchardCore.Tests/Data/ContentItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OrchardCore.Tests.Data;
public class ContentItemTests
{
[Fact]
public void NullValueDateTimeFieldSerialisationTest()
public void NullValueDateTimeFieldSerializationTest()
{
// Arrange
var jsonStr = """
Expand All @@ -21,13 +21,13 @@ public void NullValueDateTimeFieldSerialisationTest()
}
""";

var jobject = JsonNode.Parse(jsonStr);
var jObject = JsonNode.Parse(jsonStr);

var nullValueDateTimeField = jobject.SelectNode("NullValueDateTimeFieldTest").ToObject<DateTimeField>();
var nullValueDateTimeField = jObject.SelectNode("NullValueDateTimeFieldTest").ToObject<DateTimeField>();
Assert.Null(nullValueDateTimeField.Value);
Assert.Null(JObject.FromObject(nullValueDateTimeField).SelectNode("Value"));
}

/// <summary>
/// To validate <see cref="DateTimeJsonConverter"/>
/// and <seealso cref="TimeSpanJsonConverter"/>
Expand All @@ -54,11 +54,11 @@ public void JsonNode_WhenParseCalled_ConvertShortTimeFormatToTimeField()
""";

// Act
var jobject = JsonNode.Parse(jsonStr);
var timeField = jobject.SelectNode("TimeFieldTest").ToObject<TimeField>();
var dateField = jobject.SelectNode("DateFieldTest").ToObject<DateField>();
var dateTimeField = jobject.SelectNode("DateTimeFieldTest").ToObject<DateTimeField>();
var timezoneDateTimeFieldTest = jobject.SelectNode("TimezoneDateTimeFieldTest").ToObject<DateTimeField>();
var jObject = JsonNode.Parse(jsonStr);
var timeField = jObject.SelectNode("TimeFieldTest").ToObject<TimeField>();
var dateField = jObject.SelectNode("DateFieldTest").ToObject<DateField>();
var dateTimeField = jObject.SelectNode("DateTimeFieldTest").ToObject<DateTimeField>();
var timeZoneDateTimeFieldTest = jObject.SelectNode("TimezoneDateTimeFieldTest").ToObject<DateTimeField>();

// Assert
Assert.Equal("13:05:00", timeField.Value.Value.ToString());
Expand All @@ -69,7 +69,7 @@ public void JsonNode_WhenParseCalled_ConvertShortTimeFormatToTimeField()
Assert.Equal("2024-05-31T13:05:00Z", JObject.FromObject(dateTimeField).SelectNode("Value").ToString());


var utcTime = TimeZoneInfo.ConvertTimeToUtc(timezoneDateTimeFieldTest.Value.Value);
var utcTime = TimeZoneInfo.ConvertTimeToUtc(timeZoneDateTimeFieldTest.Value.Value);
Assert.Equal("2022-12-14 02:02:18", utcTime.ToString("yyyy-MM-dd HH:mm:ss"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OrchardCore.Media.Processing;
using OrchardCore.Settings;
using OrchardCore.Tests.Utilities;
using SixLabors.ImageSharp.Web.Processors;

namespace OrchardCore.Tests.Modules.OrchardCore.Media;

Expand Down
1 change: 0 additions & 1 deletion test/OrchardCore.Tests/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
global using OpenIddict.Abstractions;
global using Parlot;
global using Shortcodes;
global using SixLabors.ImageSharp.Web.Processors;
global using Xunit;
global using YesSql;
global using YesSql.Provider.SqlServer;

0 comments on commit 2176b76

Please sign in to comment.