-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix System.UriFormatException in
DefaultAssemblyDirectoryFormatter
(#…
…489) * Fix System.UriFormatException in `DefaultAssemblyDirectoryFormatter`. Rename to `IAssemblyPathFormatter` as it returns the path to the assembly, not its directory. Fixes #481 * Fix assertion on Windows * SkippableFact -> Fact
- Loading branch information
Showing
11 changed files
with
74 additions
and
80 deletions.
There are no files selected for viewing
15 changes: 0 additions & 15 deletions
15
src/RazorLight/Compilation/DefaultAssemblyDirectoryFormatter.cs
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
using System.Reflection; | ||
|
||
namespace RazorLight.Compilation | ||
{ | ||
public class DefaultAssemblyPathFormatter : IAssemblyPathFormatter | ||
{ | ||
public string GetAssemblyPath(Assembly assembly) => assembly.Location; | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
using System.Reflection; | ||
|
||
namespace RazorLight.Compilation | ||
{ | ||
public interface IAssemblyPathFormatter | ||
{ | ||
string GetAssemblyPath(Assembly assembly); | ||
} | ||
} |
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
14 changes: 0 additions & 14 deletions
14
src/RazorLight/Compilation/PassthroughAssemblyDirectoryFormatter.cs
This file was deleted.
Oops, something went wrong.
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
31 changes: 0 additions & 31 deletions
31
tests/RazorLight.Tests/Compilation/DefaultAssemblyDirectoryFormatterTest.cs
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
tests/RazorLight.Tests/Compilation/DefaultAssemblyPathFormatterTest.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,45 @@ | ||
using RazorLight.Compilation; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace RazorLight.Tests.Compilation | ||
{ | ||
public class DefaultAssemblyPathFormatterTest | ||
{ | ||
private readonly ITestOutputHelper _testOutputHelper; | ||
|
||
public DefaultAssemblyPathFormatterTest(ITestOutputHelper testOutputHelper) | ||
{ | ||
_testOutputHelper = testOutputHelper ?? throw new ArgumentNullException(nameof(testOutputHelper)); | ||
} | ||
|
||
[Fact] | ||
public void Ensure_GetAssemblyPath_Works() | ||
{ | ||
var assembly = typeof(DefaultAssemblyPathFormatterTest).Assembly; | ||
_testOutputHelper.WriteLine(assembly.Location); | ||
var directory = new DefaultAssemblyPathFormatter().GetAssemblyPath(assembly); | ||
Assert.NotNull(directory); | ||
} | ||
|
||
[Fact] | ||
public void Ensure_GetAssemblyPath_MatchesLegacy() | ||
{ | ||
var assembly = typeof(DefaultAssemblyPathFormatterTest).Assembly; | ||
_testOutputHelper.WriteLine(assembly.Location); | ||
var directory = new DefaultAssemblyPathFormatter().GetAssemblyPath(assembly); | ||
var legacyDir = new LegacyFixAssemblyPathFormatter().GetAssemblyPath(assembly); | ||
Assert.NotNull(directory); | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
// On Windows, legacy formatter returns forward-slash as separator due to UriBuilder. | ||
// So "normalise" the default one for comparison. | ||
directory = directory.Replace('\\', '/'); | ||
} | ||
|
||
Assert.Equal(legacyDir, directory); | ||
} | ||
} | ||
} |
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