Skip to content

Commit d748c82

Browse files
committed
file scoped namespaces
1 parent 9cfb61c commit d748c82

259 files changed

Lines changed: 12787 additions & 13046 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
1-
namespace ReflectionAnalyzers.Tests
2-
{
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
1+
namespace ReflectionAnalyzers.Tests;
2+
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
7+
using Gu.Roslyn.Asserts;
68

7-
using Gu.Roslyn.Asserts;
9+
using Microsoft.CodeAnalysis;
10+
using Microsoft.CodeAnalysis.Diagnostics;
811

9-
using Microsoft.CodeAnalysis;
10-
using Microsoft.CodeAnalysis.Diagnostics;
12+
using NUnit.Framework;
1113

12-
using NUnit.Framework;
14+
public static class AllAnalyzersValid
15+
{
16+
private static readonly IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers =
17+
typeof(KnownSymbol)
18+
.Assembly
19+
.GetTypes()
20+
.Where(t => typeof(DiagnosticAnalyzer).IsAssignableFrom(t) && !t.IsAbstract)
21+
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t)!)
22+
.ToArray();
23+
24+
private static readonly Solution AnalyzersProject = CodeFactory.CreateSolution(
25+
ProjectFile.Find("ReflectionAnalyzers.csproj"),
26+
settings: LibrarySettings.Roslyn);
27+
28+
private static readonly Solution ValidCodeProject = CodeFactory.CreateSolution(
29+
ProjectFile.Find("ValidCode.csproj"));
30+
31+
[Test]
32+
public static void NotEmpty()
33+
{
34+
CollectionAssert.IsNotEmpty(AllAnalyzers);
35+
Assert.Pass($"Count: {AllAnalyzers.Count}");
36+
}
37+
38+
[TestCaseSource(nameof(AllAnalyzers))]
39+
public static void ForAnalyzersProject(DiagnosticAnalyzer analyzer)
40+
{
41+
Assert.Inconclusive("Does not figure out source package.");
42+
RoslynAssert.Valid(analyzer, AnalyzersProject);
43+
}
1344

14-
public static class AllAnalyzersValid
45+
[TestCaseSource(nameof(AllAnalyzers))]
46+
public static void ForValidCode(DiagnosticAnalyzer analyzer)
1547
{
16-
private static readonly IReadOnlyList<DiagnosticAnalyzer> AllAnalyzers =
17-
typeof(KnownSymbol)
18-
.Assembly
19-
.GetTypes()
20-
.Where(t => typeof(DiagnosticAnalyzer).IsAssignableFrom(t) && !t.IsAbstract)
21-
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t)!)
22-
.ToArray();
23-
24-
private static readonly Solution AnalyzersProject = CodeFactory.CreateSolution(
25-
ProjectFile.Find("ReflectionAnalyzers.csproj"),
26-
settings: LibrarySettings.Roslyn);
27-
28-
private static readonly Solution ValidCodeProject = CodeFactory.CreateSolution(
29-
ProjectFile.Find("ValidCode.csproj"));
30-
31-
[Test]
32-
public static void NotEmpty()
33-
{
34-
CollectionAssert.IsNotEmpty(AllAnalyzers);
35-
Assert.Pass($"Count: {AllAnalyzers.Count}");
36-
}
37-
38-
[TestCaseSource(nameof(AllAnalyzers))]
39-
public static void ForAnalyzersProject(DiagnosticAnalyzer analyzer)
40-
{
41-
Assert.Inconclusive("Does not figure out source package.");
42-
RoslynAssert.Valid(analyzer, AnalyzersProject);
43-
}
44-
45-
[TestCaseSource(nameof(AllAnalyzers))]
46-
public static void ForValidCode(DiagnosticAnalyzer analyzer)
47-
{
48-
RoslynAssert.Valid(analyzer, ValidCodeProject);
49-
}
48+
RoslynAssert.Valid(analyzer, ValidCodeProject);
5049
}
5150
}
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
namespace ReflectionAnalyzers.Tests
2-
{
3-
using System.IO;
4-
using Gu.Roslyn.Asserts;
5-
using Microsoft.CodeAnalysis;
6-
using Microsoft.CodeAnalysis.CSharp;
7-
using NUnit.Framework;
1+
namespace ReflectionAnalyzers.Tests;
2+
3+
using System.IO;
4+
using Gu.Roslyn.Asserts;
5+
using Microsoft.CodeAnalysis;
6+
using Microsoft.CodeAnalysis.CSharp;
7+
using NUnit.Framework;
88

9-
public static class BinaryReference
9+
public static class BinaryReference
10+
{
11+
public static MetadataReference Compile(string code)
1012
{
11-
public static MetadataReference Compile(string code)
12-
{
13-
var binaryReferencedCompilation = CSharpCompilation.Create(
14-
"BinaryReferencedAssembly",
15-
new[] { CSharpSyntaxTree.ParseText(code) },
16-
Settings.Default.MetadataReferences,
17-
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
13+
var binaryReferencedCompilation = CSharpCompilation.Create(
14+
"BinaryReferencedAssembly",
15+
new[] { CSharpSyntaxTree.ParseText(code) },
16+
Settings.Default.MetadataReferences,
17+
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
1818

19-
using var binaryReferencedContent = new MemoryStream();
20-
var binaryEmitResult = binaryReferencedCompilation.Emit(binaryReferencedContent);
21-
Assert.That(binaryEmitResult.Diagnostics, Is.Empty);
19+
using var binaryReferencedContent = new MemoryStream();
20+
var binaryEmitResult = binaryReferencedCompilation.Emit(binaryReferencedContent);
21+
Assert.That(binaryEmitResult.Diagnostics, Is.Empty);
2222

23-
binaryReferencedContent.Position = 0;
24-
return MetadataReference.CreateFromStream(binaryReferencedContent);
25-
}
23+
binaryReferencedContent.Position = 0;
24+
return MetadataReference.CreateFromStream(binaryReferencedContent);
2625
}
2726
}

0 commit comments

Comments
 (0)