using ExtractMethod.Tooling; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; namespace BeforeAfter.Tests.ExtractMethod; /// /// Shared entry point for the ExtractMethod tests: the checked-in Demo.cs /// fixture is DATA (excluded from this project's compilation, copied to the /// output dir) and must ALWAYS be loaded through the tool's own /// so tests exercise the exact parse + /// scratch-compilation path the CLI uses. /// internal static class DemoFixture { /// Where the fixture lands after the csproj copies it (link Fixtures/). public static string Path => System.IO.Path.Combine(AppContext.BaseDirectory, "Fixtures", "Demo.cs"); /// Parse + scratch-compile the fixture once per caller. public static (SyntaxTree Tree, CSharpCompilation Compilation) Load() { if (!File.Exists(Path)) { throw new FileNotFoundException($"fixture missing at {Path}"); } var tree = CompilationLoader.ParseFile(Path); var compilation = CompilationLoader.CreateCompilation(tree, "DemoFixture"); return (tree, compilation); } }