Skip to content

Commit

Permalink
Convert to LF
Browse files Browse the repository at this point in the history
  • Loading branch information
ycanardeau committed Sep 25, 2022
1 parent a0c4aa4 commit fc5c15a
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
root = true
# All files
[*]
end_of_line = crlf
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down Expand Up @@ -65,7 +65,7 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
Expand Down
4 changes: 2 additions & 2 deletions VocaDb.ResXFileCodeGenerator.Tests/CodeGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ namespace Resources;
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.ActivityEntrySortRuleNames",
CustomToolNamespace = "Resources",
ClassName = "ActivityEntrySortRuleNames",
GroupedFile = new GroupedAdditionalFile(
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(string.Empty, Text), NewGuid()),
subFiles: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub("test.da.rex", TextDa), NewGuid()),
new AdditionalTextWithHash(new AdditionalTextStub("test.da-dk.rex", TextDaDk), NewGuid()),
}
}
),
PublicClass = publicClass,
UseVocaDbResManager = true,
Expand Down
50 changes: 25 additions & 25 deletions VocaDb.ResXFileCodeGenerator.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ namespace Resources;
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.ActivityEntrySortRuleNames",
CustomToolNamespace = "Resources",
ClassName = "ActivityEntrySortRuleNames",
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", Text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", Text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
PublicClass = publicClass,
NullForgivingOperators = nullForgivingOperators,
Expand All @@ -136,16 +136,16 @@ namespace Resources;
SourceCode.ReplaceLineEndings().Should().Be(expected.ReplaceLineEndings());
}

private static void GenerateInner(
IGenerator generator,
bool publicClass = true,
private static void GenerateInner(
IGenerator generator,
bool publicClass = true,
bool staticClass = false,
bool partial = false,
bool nullForgivingOperators = false,
bool partial = false,
bool nullForgivingOperators = false,
bool staticMembers = true,
string innerClassName = "inner",
string innerClassName = "inner",
InnerClassVisibility innerClassVisibility = InnerClassVisibility.SameAsOuter,
string innerClassInstanceName = ""
string innerClassInstanceName = ""
)
{
var expected = $@"// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -190,9 +190,9 @@ namespace Resources;
ClassName = "ActivityEntrySortRuleNames",
PublicClass = publicClass,
NullForgivingOperators = nullForgivingOperators,
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", Text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", Text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
StaticClass = staticClass,
PartialClass = partial,
Expand Down Expand Up @@ -463,9 +463,9 @@ public static class CommonMessages
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.CommonMessages",
CustomToolNamespace = null,
ClassName = "CommonMessages",
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
PublicClass = true,
NullForgivingOperators = false,
Expand Down Expand Up @@ -519,9 +519,9 @@ public static class CommonMessages
LocalNamespace = "VocaDb.Web.App_GlobalResources",
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.CommonMessages",
CustomToolNamespace = null,
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
ClassName = "CommonMessages",
PublicClass = true,
Expand Down Expand Up @@ -553,9 +553,9 @@ public void Generate_StringBuilder_Name_DuplicatedataGivesWarning()
{
LocalNamespace = "VocaDb.Web.App_GlobalResources",
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.CommonMessages",
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
CustomToolNamespace = null,
ClassName = "CommonMessages",
Expand Down Expand Up @@ -589,9 +589,9 @@ public void Generate_StringBuilder_Name_MemberSameAsFileGivesWarning()
{
LocalNamespace = "VocaDb.Web.App_GlobalResources",
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.CommonMessages",
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
CustomToolNamespace = null,
ClassName = "CommonMessages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public static class CommonMessages
LocalNamespace = "VocaDb.Web.App_GlobalResources",
EmbeddedFilename = "VocaDb.Web.App_GlobalResources.CommonMessages",
CustomToolNamespace = null,
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
ClassName = "CommonMessages",
PublicClass = true,
Expand Down Expand Up @@ -198,9 +198,9 @@ public void Generate_StringBuilder_Value_InvalidCharacter()
LocalNamespace = "VocaDb.Web.App_GlobalResources",
CustomToolNamespace = "Resources",
ClassName = "ActivityEntrySortRuleNames",
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
GroupedFile = new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub("", text), NewGuid()),
subFiles: Array.Empty<AdditionalTextWithHash>()
),
PublicClass = true,
NullForgivingOperators = false,
Expand Down
14 changes: 7 additions & 7 deletions VocaDb.ResXFileCodeGenerator.Tests/GroupResxFilesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,39 +143,39 @@ public void FileGrouping()

var testData = new List<GroupedAdditionalFile>
{
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\CaModule\Pages\IdfgControlCenter.resx"), Parse("00000000-0000-0000-0000-000000000002")),
subFiles: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\CaModule\Pages\IdfgControlCenter.da.resx"), Parse("00000000-0000-0000-0000-000000000001")),
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\CaModule\Pages\IdfgControlCenter.vi.resx"), Parse("00000000-0000-0000-0000-000000000003")),
}
),
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\CaModule\Pages\IdfgLive.resx"), Parse("00000000-0000-0000-0000-000000000005")),
subFiles: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\CaModule\Pages\IdfgLive.da.resx"), Parse("00000000-0000-0000-0000-000000000004")),
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\CaModule\Pages\IdfgLive.vi.resx"), Parse("00000000-0000-0000-0000-000000000006")),
}
),
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\Identity\Pages\Login.resx"), Parse("00000000-0000-0000-0000-000000000008")),
subFiles: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\Identity\Pages\Login.da.resx"), Parse("00000000-0000-0000-0000-000000000007")),
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\Identity\Pages\Login.vi.resx"), Parse("00000000-0000-0000-0000-000000000009")),
}
),
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\QxModule\Pages\QasdLogon.resx"), Parse("00000000-0000-0000-0000-000000000011")),
subFiles: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\QxModule\Pages\QasdLogon.da.resx"), Parse("00000000-0000-0000-0000-000000000010")),
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\QxModule\Pages\QasdLogon.vi.resx"), Parse("00000000-0000-0000-0000-000000000012")),
}
),
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\QxModule\QtrController.resx"), Parse("00000000-0000-0000-0000-000000000026")),
subFiles: new[]
{
Expand All @@ -198,14 +198,14 @@ public void FileGrouping()
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\QxModule\QtrController.vi.resx"), Parse("00000000-0000-0000-0000-000000000030")),
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\Areas\QxModule\QtrController.zh-cn.resx"), Parse("00000000-0000-0000-0000-000000000031")),
}),
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\DataAnnotations\DataAnnotation.resx"), Parse("00000000-0000-0000-0000-000000000033")),
subFiles: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\DataAnnotations\DataAnnotation.da.resx"), Parse("00000000-0000-0000-0000-000000000032"))
}
),
new GroupedAdditionalFile(
new GroupedAdditionalFile(
mainFile: new AdditionalTextWithHash(new AdditionalTextStub(@"D:\src\xhg\y\DataAnnotations\DataAnnotation2.resx"), Parse("00000000-0000-0000-0000-000000000034")),
subFiles: Array.Empty<AdditionalTextWithHash>()
)
Expand Down
10 changes: 5 additions & 5 deletions VocaDb.ResXFileCodeGenerator.Tests/HelperGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public class HelperGeneratorTests
public void CanGenerateCombo()
{
var (generatedFileName, sourceCode, errorsAndWarnings) = new StringBuilderGenerator()
.Generate(
combo: new CultureInfoCombo(
.Generate(
combo: new CultureInfoCombo(
files: new[]
{
new AdditionalTextWithHash(new AdditionalTextStub("test.da.rex"), Guid.NewGuid()),
new AdditionalTextWithHash(new AdditionalTextStub("test.da-dk.rex"), Guid.NewGuid())
}
),
cancellationToken: default
}
),
cancellationToken: default
);
var expected = @"// ------------------------------------------------------------------------------
// <auto-generated>
Expand Down
4 changes: 2 additions & 2 deletions VocaDb.ResXFileCodeGenerator.Tests/SettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ public void FileDefaults()
[InlineData(@"ProjectFolder\8 project.csproj", @"ProjectFolder\Path1.resx", "", "_8_project", "_8_project.Path1")]
[InlineData(@"ProjectFolder\8 project.csproj", @"ProjectFolder\SubFolder\Path1.resx", null, "SubFolder", "SubFolder.Path1")]
[InlineData(@"ProjectFolder\8 project.csproj", @"ProjectFolder\SubFolder\Path1.resx", "", "SubFolder", "SubFolder.Path1")]
public void FileSettings_RespectsEmptyRootNamespace(
public void FileSettings_RespectsEmptyRootNamespace(
string msBuildProjectFullPath,
string mainFile,
string rootNamespace,
string expectedLocalNamespace,
string expectedEmbeddedFilename
string expectedEmbeddedFilename
)
{
var fileOptions = FileOptions.Select(
Expand Down
2 changes: 1 addition & 1 deletion VocaDb.ResXFileCodeGenerator/InnerClassVisibility.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace VocaDb.ResXFileCodeGenerator;
namespace VocaDb.ResXFileCodeGenerator;

public enum InnerClassVisibility
{
Expand Down
2 changes: 1 addition & 1 deletion VocaDb.ResXFileCodeGenerator/NullableAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/dotnet/runtime/blob/527f9ae88a0ee216b44d556f9bdc84037fe0ebda/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
// https://github.com/dotnet/runtime/blob/527f9ae88a0ee216b44d556f9bdc84037fe0ebda/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs

#pragma warning disable
#define INTERNAL_NULLABLE_ATTRIBUTES
Expand Down
34 changes: 17 additions & 17 deletions VocaDb.ResXFileCodeGenerator/StringBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System.Text;

namespace VocaDb.ResXFileCodeGenerator;

internal static class StringBuilderExtensions
{
public static void AppendLineLF(this StringBuilder builder)
{
builder.Append('\n');
}

public static void AppendLineLF(this StringBuilder builder, string value)
{
builder.Append(value);
builder.AppendLineLF();
}
}
using System.Text;

namespace VocaDb.ResXFileCodeGenerator;

internal static class StringBuilderExtensions
{
public static void AppendLineLF(this StringBuilder builder)
{
builder.Append('\n');
}

public static void AppendLineLF(this StringBuilder builder, string value)
{
builder.Append(value);
builder.AppendLineLF();
}
}
40 changes: 20 additions & 20 deletions VocaDb.ResXFileCodeGenerator/StringBuilderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ IEnumerable<Diagnostic> ErrorsAndWarnings
{
if (options.StaticClass || options.StaticMembers)
{
errorsAndWarnings.Add(Diagnostic.Create(
errorsAndWarnings.Add(Diagnostic.Create(
descriptor: s_memberWithStaticError,
location: Location.Create(
filePath: options.GroupedFile.MainFile.File.Path,
textSpan: new TextSpan(),
lineSpan: new LinePositionSpan()
)
location: Location.Create(
filePath: options.GroupedFile.MainFile.File.Path,
textSpan: new TextSpan(),
lineSpan: new LinePositionSpan()
)
));
}

Expand Down Expand Up @@ -147,10 +147,10 @@ IEnumerable<Diagnostic> ErrorsAndWarnings
return element
.Descendants()
.Where(static data => data.Name == "data")
.Select(static data => (
key: data.Attribute("name")!.Value,
value: data.Descendants("value").First().Value,
line: (IXmlLineInfo)data.Attribute("name")!
.Select(static data => (
key: data.Attribute("name")!.Value,
value: data.Descendants("value").First().Value,
line: (IXmlLineInfo)data.Attribute("name")!
));

return null;
Expand Down Expand Up @@ -183,29 +183,29 @@ out bool resourceAccessByName
}

static Location GetMemberLocation(FileOptions fileOptions, IXmlLineInfo line, string memberName) =>
Location.Create(
filePath: fileOptions.GroupedFile.MainFile.File.Path,
Location.Create(
filePath: fileOptions.GroupedFile.MainFile.File.Path,
textSpan: new TextSpan(),
lineSpan: new LinePositionSpan(
lineSpan: new LinePositionSpan(
start: new LinePosition(line.LineNumber - 1, line.LinePosition - 1),
end: new LinePosition(line.LineNumber - 1, line.LinePosition - 1 + memberName.Length)
)
end: new LinePosition(line.LineNumber - 1, line.LinePosition - 1 + memberName.Length)
)
);

if (!alreadyAddedMembers.Add(memberName))
{
errorsAndWarnings.Add(Diagnostic.Create(
descriptor: s_duplicateWarning,
location: GetMemberLocation(options, line, memberName), memberName
errorsAndWarnings.Add(Diagnostic.Create(
descriptor: s_duplicateWarning,
location: GetMemberLocation(options, line, memberName), memberName
));
return false;
}

if (memberName == containerclassname)
{
errorsAndWarnings.Add(Diagnostic.Create(
errorsAndWarnings.Add(Diagnostic.Create(
descriptor: s_memberSameAsClassWarning,
location: GetMemberLocation(options, line, memberName), memberName
location: GetMemberLocation(options, line, memberName), memberName
));
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions VocaDb.ResXFileCodeGenerator/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public static string GetBaseName(string filePath)

// Code from: https://github.com/dotnet/ResXResourceManager/blob/c8b5798d760f202a1842a74191e6010c6e8bbbc0/src/ResXManager.VSIX/Visuals/MoveToResourceViewModel.cs#L120

public static string GetLocalNamespace(
string? resxPath,
string? targetPath,
string projectPath,
public static string GetLocalNamespace(
string? resxPath,
string? targetPath,
string projectPath,
string projectName,
string? rootNamespace
string? rootNamespace
)
{
try
Expand Down

0 comments on commit fc5c15a

Please sign in to comment.