diff --git a/DocsByReflection.UnitTests/PathHelperTest.cs b/DocsByReflection.UnitTests/PathHelperTest.cs index a28988a..2704a47 100644 --- a/DocsByReflection.UnitTests/PathHelperTest.cs +++ b/DocsByReflection.UnitTests/PathHelperTest.cs @@ -11,37 +11,24 @@ public void GetAssemblyDocFileNameFromCodeBase_NullOrEmpty_Exception() { Assert.Throws(() => { - PathHelper.GetAssemblyDocFileNameFromCodeBase(null); + PathHelper.GetAssemblyDocFileNameFromLocation(null); }); Assert.Throws(() => { - PathHelper.GetAssemblyDocFileNameFromCodeBase(""); + PathHelper.GetAssemblyDocFileNameFromLocation(""); }); } - [Test()] - public void GetAssemblyDocFileNameFromCodeBase_DoesNotStartWithPrefix_Exception() - { - Assert.Throws(() => - { - PathHelper.GetAssemblyDocFileNameFromCodeBase("file://notExists"); - }, "Could not ascertain assembly filename from assembly code base 'file://notExists'."); - } - [Test()] public void GetAssemblyDocFileNameFromCodeBase_RightCodeBase_DocFileName() { - var actual = PathHelper.GetAssemblyDocFileNameFromCodeBase("file:///Users/giacomelli/Dropbox/jogosdaqui/Plataforma/src/jogosdaqui.WebApi/Bin/jogosdaqui.WebApi.dll"); + var actual = PathHelper.GetAssemblyDocFileNameFromLocation("c:/Users/giacomelli/Dropbox/jogosdaqui/Plataforma/src/jogosdaqui.WebApi/Bin/jogosdaqui.WebApi.dll"); - if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix) - { - Assert.AreEqual("/Users/giacomelli/Dropbox/jogosdaqui/Plataforma/src/jogosdaqui.WebApi/Bin/jogosdaqui.WebApi.xml", actual); - } - else - { - Assert.AreEqual("Users/giacomelli/Dropbox/jogosdaqui/Plataforma/src/jogosdaqui.WebApi/Bin/jogosdaqui.WebApi.xml", actual); - } + Assert.AreEqual( + "c:/Users/giacomelli/Dropbox/jogosdaqui/Plataforma/src/jogosdaqui.WebApi/Bin/jogosdaqui.WebApi.xml", + actual + ); } } } diff --git a/DocsByReflection/DocsAssemblyService.cs b/DocsByReflection/DocsAssemblyService.cs index b5c3bad..faf1538 100644 --- a/DocsByReflection/DocsAssemblyService.cs +++ b/DocsByReflection/DocsAssemblyService.cs @@ -77,7 +77,7 @@ public static XmlDocument GetXmlFromAssembly(Assembly assembly, bool throwError /// The XML document private static XmlDocument GetXmlFromAssemblyNonCached(Assembly assembly) { - string filePath = PathHelper.GetAssemblyDocFileNameFromCodeBase(assembly.CodeBase); + string filePath = PathHelper.GetAssemblyDocFileNameFromLocation(assembly.Location); try { diff --git a/DocsByReflection/PathHelper.cs b/DocsByReflection/PathHelper.cs index 78601a8..bcc9000 100644 --- a/DocsByReflection/PathHelper.cs +++ b/DocsByReflection/PathHelper.cs @@ -8,33 +8,19 @@ namespace DocsByReflection /// public static class PathHelper { - #region Methods - /// - /// Gets the assembly document file name from code base. - /// - /// The assembly document file name from code base. - /// Assemby code base. - public static string GetAssemblyDocFileNameFromCodeBase(string assemblyCodeBase) + #region Methods + /// + /// Gets the assembly document file name from location. + /// + /// The assembly document file name from location. + /// Assemby location. + public static string GetAssemblyDocFileNameFromLocation(string assemblyLocation) { - if (string.IsNullOrWhiteSpace (assemblyCodeBase)) { - throw new ArgumentNullException ("assemblyCodeBase"); + if (string.IsNullOrWhiteSpace (assemblyLocation)) { + throw new ArgumentNullException (nameof(assemblyLocation)); } - var prefix = "file:///"; - - if (assemblyCodeBase.StartsWith (prefix, StringComparison.OrdinalIgnoreCase)) { - var filePath = assemblyCodeBase.Substring (prefix.Length); - - if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix) { - filePath = "/" + filePath; - } - - return Path.ChangeExtension (filePath, ".xml"); - } - else - { - throw new DocsByReflectionException(string.Format("Could not ascertain assembly filename from assembly code base '{0}'.", assemblyCodeBase)); - } + return Path.ChangeExtension (assemblyLocation, ".xml"); } #endregion }