-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8415fcf
commit 47785e7
Showing
9 changed files
with
58 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<Project> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-1.final" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0-1.final" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.final" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0-3.final" /> | ||
<PackageReference Include="Mono.Cecil"><Version>0.11.6</Version></PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Cecilifier.Core.Tests/TestResources/Integration/Members/Methods/RefProperties.cs.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Cecilifier.Core.Tests/Tests/Unit/MemberDependencies/MemberDependencyTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Cecilifier.Core.AST.MemberDependencies; | ||
Check failure on line 7 in Cecilifier.Core.Tests/Tests/Unit/MemberDependencies/MemberDependencyTestBase.cs
|
||
using Cecilifier.Core.Tests.Tests.Unit.Framework; | ||
|
||
namespace Cecilifier.Core.Tests.Tests.Unit; | ||
|
||
public class MemberDependencyTestBase | ||
{ | ||
private protected IReadOnlyCollection<MemberDependency> CollectDependenciesFromSingleType(CSharpCompilation compilation) | ||
{ | ||
var collector = new MemberDependencyCollector<MemberDependency>(); | ||
|
||
var typeUnderTest = compilation.SyntaxTrees[0].GetRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Single(); | ||
var computedDependencies = collector.Process(typeUnderTest, compilation.GetSemanticModel(compilation.SyntaxTrees[0])); | ||
return computedDependencies; | ||
} | ||
|
||
protected static CSharpCompilation CompilationFor(params string[] code) | ||
{ | ||
var syntaxTrees = code.Select(source => CSharpSyntaxTree.ParseText(source)); | ||
var comp = CSharpCompilation.Create("Test", syntaxTrees, Basic.Reference.Assemblies.Net90.References.All, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); | ||
|
||
var errors = comp.GetDiagnostics() | ||
.Where(d => d.Severity == DiagnosticSeverity.Error) | ||
.Select(d => d.GetMessage()) | ||
.ToArray(); | ||
|
||
if (errors.Any()) | ||
throw new ArgumentException($"Code has compilation errors:\n\t{string.Join("\n\t", errors)}"); | ||
return comp; | ||
} | ||
|
||
internal static string MemberNameFrom(MemberDependency dependency) => dependency.Declaration.MemberName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters