Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,36 @@ public async Task VerifyEditorConfigSettingsAreReadCorrectlyAsync()
Assert.Equal(OptionSetting.Allow, styleCopSettings.OrderingRules.BlankLinesBetweenUsingGroups);
}

[Fact]
public async Task VerifyFileHeaderTemplateFromEditorConfigAsync()
{
var settings = @"root = true

[*]
file_header_template = Line 1\nLine 2.
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);

Assert.Equal("Line 1\nLine 2.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}

[Fact]
public async Task VerifyStyleCopDocumentationCopyrightTextFromEditorConfigAsync()
{
var settings = @"root = true

[*]
stylecop.documentation.copyrightText = Line 1\nLine 2.
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);

Assert.Equal("Line 1\nLine 2.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}

[Theory]
[CombinatorialData]
public async Task VerifyBooleanDocumentationSettingsFromEditorConfigAsync(bool value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ internal static string TryGetStringValue(AnalyzerConfigOptionsWrapper analyzerCo
return null;
}

internal static string TryGetMultiLineStringValue(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key, bool allowExplicitUnset = true)
{
var orgValue = TryGetStringValue(analyzerConfigOptions, key, allowExplicitUnset);
return orgValue?.Replace("\\r", "\r").Replace("\\n", "\n");
}

internal static KeyValuePair<string, string>? TryGetStringValueAndNotification(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key, bool allowExplicitUnset = true)
{
if (analyzerConfigOptions.TryGetValue(key, out var value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ protected internal DocumentationSettings(JsonObject documentationSettingsObject,
documentPrivateFields ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentPrivateFields");

companyName ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.companyName");
copyrightText ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.copyrightText")
?? AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "file_header_template");
copyrightText ??= AnalyzerConfigHelper.TryGetMultiLineStringValue(analyzerConfigOptions, "stylecop.documentation.copyrightText")
?? AnalyzerConfigHelper.TryGetMultiLineStringValue(analyzerConfigOptions, "file_header_template");
headerDecoration ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.headerDecoration");

xmlHeader ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.xmlHeader");
Expand Down