From 605f9aeb3292fbc15a4a63717069384f6aebd789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Kurai?= Date: Fri, 15 Oct 2021 11:41:33 +0200 Subject: [PATCH] normalize line endings after file generation, add roslynator suppression --- .vscode/spellright.dict | 1 + CHANGELOG.md | 4 ++++ .../ResourcePaths.cs | 2 ++ .../Editor/Generation/ResourceFileGenerator.cs | 9 +++++++++ .../Assets/AutSoft.UnityResourceGenerator/package.json | 2 +- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.vscode/spellright.dict b/.vscode/spellright.dict index 5574ec4..63c2875 100644 --- a/.vscode/spellright.dict +++ b/.vscode/spellright.dict @@ -1,2 +1,3 @@ unrecoverably parameterless +Roslynator diff --git a/CHANGELOG.md b/CHANGELOG.md index 5021ef1..3d2a4f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.5.0 +- Normalize line endings to Windows CLRF +- Add Roslynator suppression to line endings + # 0.4.1 - Add license URL to package diff --git a/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator.Sample/ResourcePaths.cs b/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator.Sample/ResourcePaths.cs index 628f431..f75b2d3 100644 --- a/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator.Sample/ResourcePaths.cs +++ b/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator.Sample/ResourcePaths.cs @@ -6,6 +6,8 @@ namespace AutSoft.UnityResourceGenerator.Sample // ReSharper disable PartialTypeWithSinglePart // ReSharper disable InconsistentNaming // ReSharper disable IncorrectBlankLinesNearBraces +#pragma warning disable IDE0079 // Remove unnecessary suppression +#pragma warning disable RCS1036 // Remove redundant empty line. public static partial class ResourcePaths { public static partial class Scenes diff --git a/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/ResourceFileGenerator.cs b/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/ResourceFileGenerator.cs index 930b76f..38d7d07 100644 --- a/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/ResourceFileGenerator.cs +++ b/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/ResourceFileGenerator.cs @@ -2,11 +2,14 @@ using System; using System.Linq; using System.Text; +using System.Text.RegularExpressions; namespace AutSoft.UnityResourceGenerator.Editor.Generation { public static class ResourceFileGenerator { + private static readonly Regex NormalizedLineEndings = new Regex(@"\r\n|\n\r|\n|\r", RegexOptions.Compiled, TimeSpan.FromSeconds(10)); + public static string CreateResourceFile(ResourceContext context) { // ReSharper disable once MissingIndent @@ -17,6 +20,8 @@ namespace {0} // ReSharper disable PartialTypeWithSinglePart // ReSharper disable InconsistentNaming // ReSharper disable IncorrectBlankLinesNearBraces +#pragma warning disable IDE0079 // Remove unnecessary suppression +#pragma warning disable RCS1036 // Remove redundant empty line. public static partial class {1} {"; @@ -31,6 +36,8 @@ public static partial class {1} // ReSharper disable PartialTypeWithSinglePart // ReSharper disable InconsistentNaming // ReSharper disable IncorrectBlankLinesNearBraces +#pragma warning disable IDE0079 // Remove unnecessary suppression +#pragma warning disable RCS1036 // Remove redundant empty line. public static partial class {1} {"; @@ -63,6 +70,8 @@ public static partial class {1} .OrderByDescending(p => p.PostProcessPriority) .Aggregate(fileContent, (current, processor) => processor.PostProcess(context, current)); + fileContent = NormalizedLineEndings.Replace(fileContent, "\r\n"); + return fileContent; } } diff --git a/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/package.json b/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/package.json index 36e6caf..ddad40d 100644 --- a/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/package.json +++ b/UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/package.json @@ -1,6 +1,6 @@ { "name": "com.autsoft.unityresourcegenerator", - "version": "0.4.1", + "version": "0.5.0", "displayName": "Unity Resource Generator", "description": "Generate path strings for Resources.Load", "license": "MIT",