From 1aef84b50d8afd91d2d5e23596596724d8e5d9dd Mon Sep 17 00:00:00 2001 From: sornaks Date: Thu, 6 Aug 2015 10:31:11 -0700 Subject: [PATCH] Issue #2745 - ViewHierarchyUtility.GetHierarchicalPath does not handle root paths *nix file systems. Fix: It is not necessary to check for root paths in this place because ViewHierarchyUtility.GetHierarchicalPath is always called with a relative path. Hence removing the check. --- .../ViewHierarchyUtility.cs | 6 ---- .../ViewHierarchyUtilityTest.cs | 30 ------------------- 2 files changed, 36 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/ViewHierarchyUtility.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/ViewHierarchyUtility.cs index 9824ac3cf3..aea88d7e8a 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/ViewHierarchyUtility.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/ViewHierarchyUtility.cs @@ -68,12 +68,6 @@ namespace Microsoft.AspNet.Mvc.Razor relativePath = relativePath.Substring(1); } - if (Path.IsPathRooted(relativePath)) - { - // If the path looks like it's not app relative, don't attempt to construct paths. - return Enumerable.Empty(); - } - if (string.Equals(Path.GetFileName(relativePath), fileName, StringComparison.OrdinalIgnoreCase)) { // If the specified path is for the file hierarchy being constructed, then the first file that applies diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs index 8b9da981fe..4ade3731ef 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs @@ -221,35 +221,5 @@ namespace Microsoft.AspNet.Mvc.Razor // Assert Assert.Empty(result); } - - [ConditionalTheory] - // https://github.com/aspnet/Mvc/issues/2745 - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public void GetViewStartLocations_ReturnsEmptySequence_IfPathIsRooted() - { - // Arrange - var absolutePath = Path.Combine(Directory.GetCurrentDirectory(), "Index.cshtml"); - - // Act - var result = ViewHierarchyUtility.GetViewStartLocations(absolutePath); - - // Assert - Assert.Empty(result); - } - - [ConditionalTheory] - // https://github.com/aspnet/Mvc/issues/2745 - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public void GetViewImportsLocations_ReturnsEmptySequence_IfPathIsRooted() - { - // Arrange - var absolutePath = Path.Combine(Directory.GetCurrentDirectory(), "Index.cshtml"); - - // Act - var result = ViewHierarchyUtility.GetViewImportsLocations(absolutePath); - - // Assert - Assert.Empty(result); - } } } \ No newline at end of file