C24.ReVersion.ProjectPathHelper.ResolveProjectRelativePath C# (CSharp) Method

ResolveProjectRelativePath() public method

public ResolveProjectRelativePath ( string projectFile, string projectRelativePath ) : string
projectFile string
projectRelativePath string
return string
        public string ResolveProjectRelativePath(string projectFile, string projectRelativePath)
        {
            if (projectFile == null)
            {
                throw new ArgumentNullException("projectFile");
            }

            if (projectRelativePath == null)
            {
                throw new ArgumentNullException("projectRelativePath");
            }

            projectFile = projectFile.Replace('\\', Path.DirectorySeparatorChar);
            projectRelativePath = projectRelativePath.Replace('\\', Path.DirectorySeparatorChar);

            var baseUri = new Uri(projectFile, UriKind.Absolute);
            var relativeUri = new Uri(projectRelativePath, UriKind.Relative);
            return Path.GetFullPath(new Uri(baseUri, relativeUri).LocalPath);
        }

Usage Example

        public void ResolveProjectRelativePath_Should_Resolve_Paths_Beneath_The_Project_Root_Using_Dot_Notation()
        {
            var helper = new ProjectPathHelper(Mock.Of<IFileSystem>());
            var result = helper.ResolveProjectRelativePath("|dev|projects|test-project.csproj".Path(), ".|subdir-1|text-file.txt".Path());

            Assert.AreEqual("|dev|projects|subdir-1|text-file.txt".Path(), result);
        }
All Usage Examples Of C24.ReVersion.ProjectPathHelper::ResolveProjectRelativePath