Source/Fuse/Tests/Solution/SolutionTestsHelper.cs
/// <summary>
/// Finds the physical path of the Visual Studio Project File the assembly is compiled from.
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <returns>The physical path of the  Visual Studio Project File the assembly is compiled from.</returns>
Finds the physical path of the Visual Studio Project File the assembly is compiled from.
Finds the physical path of the Visual Studio Project File the assembly is compiled from .
public static string FindProjectPathOf(Assembly assembly)
        {
            if (assembly == null)
                throw new ArgumentNullException(nameof(assembly));
            var assemblyPath = assembly.GetPhysicalLocation();
            if (String.IsNullOrEmpty(assemblyPath))
            {
                throw new FileNotFoundException($"Could not find a physical path for '{assembly}'.");
            }
            FileInfo assemblyFile = new FileInfo(assemblyPath);
            DirectoryInfo parentDirectory = assemblyFile.Directory;
            string fileNotFoundMessage = $"Couldn't find a Project file for '{assembly}'.";
            string projectFileName = Path.ChangeExtension(assemblyFile.Name, "csproj");
            try
            {
                while ((parentDirectory = parentDirectory.Parent) != null)
                {
                    FileInfo[] solutionFiles = parentDirectory.GetFiles(projectFileName, SearchOption.AllDirectories);
                    if (solutionFiles.Length > 0)
                        return solutionFiles[0].FullName;
                }
            }
            catch (Exception exception)
            {
                throw new FileNotFoundException(fileNotFoundMessage, exception);
            }
            throw new FileNotFoundException(fileNotFoundMessage);
        }
public static string FindProjectPathOf ( Assembly assembly ) { if ( assembly == null ) throw new ArgumentNullException ( nameof ( assembly ) ) ; var assemblyPath = assembly . GetPhysicalLocation ( ) ; if ( String . IsNullOrEmpty ( assemblyPath ) ) { throw new FileNotFoundException ( $" Could not find a physical path for ' { assembly } '. " ) ; } FileInfo assemblyFile = new FileInfo ( assemblyPath ) ; DirectoryInfo parentDirectory = assemblyFile . Directory ; string fileNotFoundMessage = $" Couldn't find a Project file for ' { assembly } '. " ; string projectFileName = Path . ChangeExtension ( assemblyFile . Name , " " ) ; try { while ( ( parentDirectory = parentDirectory . Parent ) != null ) { FileInfo [ ] solutionFiles = parentDirectory . GetFiles ( projectFileName , SearchOption . AllDirectories ) ; if ( solutionFiles . Length > 0 ) return solutionFiles [ 0 ] . FullName ; } } catch ( Exception exception ) { throw new FileNotFoundException ( fileNotFoundMessage , exception ) ; } throw new FileNotFoundException ( fileNotFoundMessage ) ; }
Finds the physical path of the Visual Studio Project File the assembly is compiled from.
Finds the physical path of the Visual Studio Project File the assembly is compiled from .
The physical path of the  Visual Studio Project File the assembly is compiled from.
The physical path of the Visual Studio Project File the assembly is compiled from .
assembly
Assembly
None