Skip to content

Commit

Permalink
Cleaned up an edge case in AnalyzeCSharp where the full base path is …
Browse files Browse the repository at this point in the history
…just a slash. Also fixed some edge cases with root pathing in the test file provider.
  • Loading branch information
daveaglick committed Dec 22, 2023
1 parent d8d2f65 commit a0eb115
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904;CA1724</WarningsNotAsErrors>
</PropertyGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\LICENSE.md" Pack="true" PackagePath=""/>
Expand Down
8 changes: 6 additions & 2 deletions src/core/Statiq.Testing/IO/TestDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Statiq.Common;

Expand All @@ -16,14 +17,17 @@ public TestDirectory(IReadOnlyFileSystem fileSystem, TestFileProvider fileProvid
{
_fileSystem = fileSystem;
_fileProvider = fileProvider;
Path = path;

// Use a slash for an empty path (can't compare to NormalizePath.Empty since this might be absolute
// in the case of a ".." from the globber, and that's always relative, so compare against FullPath)
Path = path.FullPath == string.Empty ? NormalizedPath.Slash : path;
}

public NormalizedPath Path { get; }

NormalizedPath IFileSystemEntry.Path => Path;

public bool Exists => _fileProvider.Directories.Contains(Path);
public bool Exists => Path == NormalizedPath.Slash || _fileProvider.Directories.Contains(Path);

public DateTime LastWriteTime { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/core/Statiq.Testing/IO/TestFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ public void AddFile(NormalizedPath path, string content = "")

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
}
3 changes: 2 additions & 1 deletion src/extensions/Statiq.CodeAnalysis/AnalyzeCSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ protected override async Task<IEnumerable<IDocument>> ExecuteContextAsync(IExecu
.WithReferences(mscorlib)
.WithOptions(new CSharpCompilationOptions(
OutputKind.DynamicallyLinkedLibrary,
xmlReferenceResolver: new XmlFileResolver(context.FileSystem.RootPath.FullPath)));
xmlReferenceResolver: new XmlFileResolver(
context.FileSystem.RootPath.FullPath == NormalizedPath.Slash ? null : context.FileSystem.RootPath.FullPath)));

// Add the input source and references
List<ISymbol> symbols = new List<ISymbol>();
Expand Down

0 comments on commit a0eb115

Please sign in to comment.