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

OSOE-49: Enforce Windows newlines for C# files to avoid false positives with IDE0055 warning. #16

Merged
merged 11 commits into from
May 26, 2022
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
* text=auto

# Enforce Windows newlines for C# files to avoid false positives with IDE0055 warning.
# See https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/issues/106 for more information.
*.cs text eol=crlf
1 change: 0 additions & 1 deletion Lombiq.BaseTheme.Samples/Lombiq.BaseTheme.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFramework>net6.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**;Tests\**</DefaultItemExcludes>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
9 changes: 6 additions & 3 deletions Lombiq.BaseTheme.Samples/Services/ResourceFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
namespace Lombiq.DataTables.Samples.Navigation;

// This service implements conditional configuration to direct the ResourceFilterMiddleware when and what styles need to
// be added to the resources.
// be added to the resources. The attribute indicates that the middleware should only invoke this provider if the
// current admin or site theme is equal to the one in the attribute constructor.
[ResourceFilterThemeRequirement(FeatureIds.BaseThemeSamples)]
public class ResourceFilters : IResourceFilterProvider
{
public void AddResourceFilter(ResourceFilterBuilder builder)
{
// We always want to add the site style. If you only have "Always" styles then it's easier to inject them via
// the Views/Widget-LayoutInjection.cshtml file and skip using a ResourceFilterMiddleware.
// We always want to add the site style. If you only have "Always" styles and you are going to override
// Views/Widget-LayoutInjection.cshtml anyway, then it's easier to inject your style there and skip using a
// ResourceFilterMiddleware altogether.
builder.Always().RegisterStylesheet(ResourceNames.Site);
builder.WhenContentType("BlogPost").RegisterStylesheet(ResourceNames.BlogPost);
}
Expand Down
2 changes: 2 additions & 0 deletions Lombiq.BaseTheme.Samples/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.ResourceManagement;
using System;
using System.Threading.Tasks;
using static Lombiq.BaseTheme.Samples.Constants.FeatureIds;

namespace Lombiq.BaseTheme.Samples;
Expand Down
Binary file added Lombiq.BaseTheme.Samples/wwwroot/Theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Lombiq.BaseTheme.Tests.UI/Lombiq.BaseTheme.Tests.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.Tests.UI" Version="2.1.1" />
<PackageReference Include="Lombiq.Tests.UI" Version="2.2.0-alpha.6" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Lombiq.BaseTheme/Lombiq.BaseTheme.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
<ProjectReference Include="..\..\..\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.csproj" />
<ProjectReference Include="..\..\..\Modules\Lombiq.HelpfulExtensions\Lombiq.HelpfulExtensions.csproj" />
<ProjectReference Include="..\..\..\Utilities\Lombiq.Gulp.Extensions\Lombiq.Gulp.Extensions.csproj" />
<ProjectReference Include="..\..\..\Utilities\Lombiq.Npm.Targets\Lombiq.Npm.Targets.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(NuGetBuild)' == 'true'">
<PackageReference Include="Lombiq.HelpfulLibraries" Version="4.2.0" />
<PackageReference Include="Lombiq.HelpfulLibraries" Version="4.2.1-alpha.4" />
<PackageReference Include="Lombiq.HelpfulExtensions" Version="3.2.0" />

<Content Include="Assets/Styles/**/*.*">
Expand Down
11 changes: 11 additions & 0 deletions Lombiq.BaseTheme/Services/ResourceFilters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Lombiq.BaseTheme.Constants;
using Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement;

namespace Lombiq.DataTables.Navigation;

[ResourceFilterThemeRequirement(FeatureIds.BaseTheme)]
public class ResourceFilters : IResourceFilterProvider
{
public void AddResourceFilter(ResourceFilterBuilder builder) =>
builder.Always().RegisterStylesheet(ResourceNames.Site);
}
0liver marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions Lombiq.BaseTheme/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Lombiq.BaseTheme.Migrations;
using Lombiq.BaseTheme.Services;
using Lombiq.DataTables.Navigation;
using Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand All @@ -18,5 +20,7 @@ public override void ConfigureServices(IServiceCollection services)
services.Configure<MvcOptions>(options => options.Filters.Add(typeof(MainMenuWidgetFilter)));

services.AddScoped<IDataMigration, LayoutInjectionMigrations>();

services.AddScoped<IResourceFilterProvider, ResourceFilters>();
}
}
Binary file added Lombiq.BaseTheme/wwwroot/Theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.