Skip to content

Commit

Permalink
Initial conversion to use File scoped namespaces
Browse files Browse the repository at this point in the history
Fixes #148
  • Loading branch information
mrlacey committed Jun 14, 2022
1 parent 8f23803 commit 42ca623
Show file tree
Hide file tree
Showing 40 changed files with 1,516 additions and 1,556 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ dotnet_diagnostic.SA1634.severity = none
dotnet_diagnostic.SA1652.severity = none
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
using System.Collections.Immutable;
using System.Linq;

namespace CommunityToolkit.Labs.Core.SourceGenerators.Tests
namespace CommunityToolkit.Labs.Core.SourceGenerators.Tests;

public partial class ToolkitSampleMetadataTests
{
public partial class ToolkitSampleMetadataTests
{
// We currently need at least one sample to test the document registry, so we'll have this for the base cases to share.
private static readonly string SimpleSource = $@"
// We currently need at least one sample to test the document registry, so we'll have this for the base cases to share.
private static readonly string SimpleSource = $@"
using System.ComponentModel;
using CommunityToolkit.Labs.Core.SourceGenerators;
using CommunityToolkit.Labs.Core.SourceGenerators.Attributes;
Expand All @@ -32,26 +32,26 @@ namespace Windows.UI.Xaml.Controls
public class UserControl {{ }}
}}";

[TestMethod]
public void MissingFrontMatterSection()
{
string markdown = @"
[TestMethod]
public void MissingFrontMatterSection()
{
string markdown = @"
# This is some test documentation...
Without any front matter.
";

VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown, DiagnosticDescriptors.MarkdownYAMLFrontMatterException.Id, DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id);
}

[DataRow(1, DisplayName = "Title")]
[DataRow(3, DisplayName = "Description")]
[DataRow(4, DisplayName = "Keywords")]
[DataRow(7, DisplayName = "Category")]
[DataRow(8, DisplayName = "Subcategory")]
[TestMethod]
public void MissingFrontMatterField(int removeline)
{
string markdown = @"---
VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown, DiagnosticDescriptors.MarkdownYAMLFrontMatterException.Id, DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id);
}

[DataRow(1, DisplayName = "Title")]
[DataRow(3, DisplayName = "Description")]
[DataRow(4, DisplayName = "Keywords")]
[DataRow(7, DisplayName = "Category")]
[DataRow(8, DisplayName = "Subcategory")]
[TestMethod]
public void MissingFrontMatterField(int removeline)
{
string markdown = @"---
title: Canvas Layout
author: mhawker
description: A canvas-like VirtualizingLayout for use in an ItemsRepeater
Expand All @@ -65,18 +65,18 @@ public void MissingFrontMatterField(int removeline)
> [!SAMPLE Sample]
Without any front matter.";

// Remove the field we want to test is missing.
var lines = markdown.Split('\n').ToList();
lines.RemoveAt(removeline);
markdown = String.Join('\n', lines);
// Remove the field we want to test is missing.
var lines = markdown.Split('\n').ToList();
lines.RemoveAt(removeline);
markdown = String.Join('\n', lines);

VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown, DiagnosticDescriptors.MarkdownYAMLFrontMatterMissingField.Id, DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id); // We won't see the sample reference as we bail out when the front matter fails to be complete...
}
VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown, DiagnosticDescriptors.MarkdownYAMLFrontMatterMissingField.Id, DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id); // We won't see the sample reference as we bail out when the front matter fails to be complete...
}

[TestMethod]
public void MarkdownInvalidSampleReference()
{
string markdown = @"---
[TestMethod]
public void MarkdownInvalidSampleReference()
{
string markdown = @"---
title: Canvas Layout
author: mhawker
description: A canvas-like VirtualizingLayout for use in an ItemsRepeater
Expand All @@ -91,15 +91,15 @@ public void MarkdownInvalidSampleReference()
Without any front matter.
";

VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown,
DiagnosticDescriptors.MarkdownSampleIdNotFound.Id,
DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id);
}
VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown,
DiagnosticDescriptors.MarkdownSampleIdNotFound.Id,
DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id);
}

[TestMethod]
public void DocumentationMissingSample()
{
string markdown = @"---
[TestMethod]
public void DocumentationMissingSample()
{
string markdown = @"---
title: Canvas Layout
author: mhawker
description: A canvas-like VirtualizingLayout for use in an ItemsRepeater
Expand All @@ -112,15 +112,15 @@ public void DocumentationMissingSample()
# This is some test documentation...
Without any front matter.";

VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown,
DiagnosticDescriptors.DocumentationHasNoSamples.Id,
DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id);
}
VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown,
DiagnosticDescriptors.DocumentationHasNoSamples.Id,
DiagnosticDescriptors.SampleNotReferencedInMarkdown.Id);
}

[TestMethod]
public void DocumentationValid()
{
string markdown = @"---
[TestMethod]
public void DocumentationValid()
{
string markdown = @"---
title: Canvas Layout
author: mhawker
description: A canvas-like VirtualizingLayout for use in an ItemsRepeater
Expand All @@ -134,7 +134,6 @@ public void DocumentationValid()
Without any front matter.
> [!SAMPLE Sample]";

VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown);
}
VerifyGeneratedDiagnostics<ToolkitSampleMetadataGenerator>(SimpleSource, markdown);
}
}
Loading

0 comments on commit 42ca623

Please sign in to comment.