Skip to content

Commit

Permalink
Merge pull request #16 from mmajcica/OsFriendlyName
Browse files Browse the repository at this point in the history
Implemented  Enhancement #1
  • Loading branch information
haacked committed Sep 26, 2014
2 parents 58870bb + 4d8d126 commit e268287
Show file tree
Hide file tree
Showing 22 changed files with 726 additions and 53 deletions.
10 changes: 10 additions & 0 deletions Tests/NullGuardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@ public void MakeSureNullGuardIsWorking()
Assert.Throws<ArgumentNullException>(() => new FileInfo(null));
#endif
}

[Fact]
public void CheckOSVersionImplementation()
{
Environment env = new Environment();

Assert.NotNull(env.OSVersion.Edition);
Assert.NotNull(env.OSVersion.Name);
Assert.True(env.OSVersion.ToString().Length > 7);
}
}
}
4 changes: 2 additions & 2 deletions src/AssemblyFacade.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using NullGuard;
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using NullGuard;

namespace Rothko
{
Expand Down
6 changes: 3 additions & 3 deletions src/DirectoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public IEnumerable<IDirectoryInfo> EnumerateDirectories(string searchPattern)
return inner.EnumerateDirectories(searchPattern).Select(Wrap);
}

public IEnumerable<IDirectoryInfo> EnumerateDirectories(string searchPattern, System.IO.SearchOption searchOption)
public IEnumerable<IDirectoryInfo> EnumerateDirectories(string searchPattern, SearchOption searchOption)
{
return inner.EnumerateDirectories(searchPattern, searchOption).Select(Wrap);
}
Expand All @@ -103,7 +103,7 @@ public IEnumerable<IFileInfo> EnumerateFiles(string searchPattern)
return inner.EnumerateFiles(searchPattern).Select(FileInfo.Wrap);
}

public IEnumerable<IFileInfo> EnumerateFiles(string searchPattern, System.IO.SearchOption searchOption)
public IEnumerable<IFileInfo> EnumerateFiles(string searchPattern, SearchOption searchOption)
{
return inner.EnumerateFiles(searchPattern, searchOption).Select(FileInfo.Wrap);
}
Expand All @@ -118,7 +118,7 @@ public IEnumerable<IFileSystemInfo> EnumerateFileSystemInfos(string searchPatter
return inner.EnumerateFileSystemInfos(searchPattern).Select(Wrap);
}

public IEnumerable<IFileSystemInfo> EnumerateFileSystemInfos(string searchPattern, System.IO.SearchOption searchOption)
public IEnumerable<IFileSystemInfo> EnumerateFileSystemInfos(string searchPattern, SearchOption searchOption)
{
return inner.EnumerateFileSystemInfos(searchPattern, searchOption).Select(Wrap);
}
Expand Down
1 change: 0 additions & 1 deletion src/FileInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using System;
using System.Diagnostics;

namespace Rothko
Expand Down
4 changes: 2 additions & 2 deletions src/FileSystemWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public System.IO.WaitForChangedResult WaitForChanged(System.IO.WatcherChangeType
Justification = "It doesn't!")]
public override bool Equals([AllowNull] object obj)
{
if (Object.ReferenceEquals(this, obj))
if (ReferenceEquals(this, obj))
return true;
if (Object.ReferenceEquals(null, obj))
if (ReferenceEquals(null, obj))
return false;

var other = obj as FileSystemWatcher;
Expand Down
Binary file added src/GlobalSuppressions.cs
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Infrastructure/DirectoryFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public bool IsEmpty(string path)
throw new DirectoryNotFoundException(
String.Format(CultureInfo.InvariantCulture, "The directory '{0}' does not exist", path));
}
return directory.IsEmpty;

return directory.IsEmpty;
}
}
}
2 changes: 1 addition & 1 deletion src/Infrastructure/IDialogFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface IDialogFacade
}

[SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes",
Justification = "TODO: Should tchis even be a struct?")]
Justification = "TODO: Should this even be a struct?")]
public struct SaveDialogResult
{
readonly bool _success;
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/IDirectoryFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface IDirectoryFacade
/// Returns true if the directory exists at the specified path.
/// </summary>
/// <param name="path">Path to the directory</param>
/// <returns>True if the directory exists, otherewise false.</returns>
/// <returns>True if the directory exists, otherwise false.</returns>
bool Exists(string path);

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/Infrastructure/IDirectoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public interface IDirectoryInfo : IFileSystemInfo
/// </summary>
/// <param name="directorySecurity">The access control to apply to the directory.</param>
/// <exception cref="T:System.IO.IOException">
/// The directory specified by <paramref name="path"/> is read-only or is not empty.
/// The directory specified by <paramref name="directorySecurity"/> is read-only or is not empty.
/// </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// The caller does not have the required permission.
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path"/> is a zero-length string, contains only white space, or contains one or more
/// invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars"/>.
/// <paramref name="directorySecurity"/> is a zero-length string, contains only white space, or contains one or more
/// invalid characters as defined by <see cref="F:System.IO.Path.GetInvalidFilenameChars"/>.
/// </exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="path"/> is null.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="directorySecurity"/> is null.</exception>
/// <exception cref="T:System.IO.PathTooLongException">
/// The specified path, file name, or both exceed the system-defined maximum length. For example, on
/// Windows-based platforms, paths must be less than 248 characters, and file names must be less than
Expand All @@ -73,7 +73,7 @@ public interface IDirectoryInfo : IFileSystemInfo
/// Creating a directory with only the colon (:) character was attempted.
/// </exception>
/// <exception cref="T:System.IO.IOException">
/// The directory specified by <paramref name="path"/> is read-only or is not empty.
/// The directory specified by <paramref name="directorySecurity"/> is read-only or is not empty.
/// </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
Expand Down
20 changes: 10 additions & 10 deletions src/Infrastructure/IFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public interface IFileInfo : IFileSystemInfo
/// <summary>Creates a read-only <see cref="T:System.IO.FileStream"/>.</summary>
/// <returns>A new read-only <see cref="T:Rothko.IFileStream"/> object.</returns>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path"/> is read-only or is a directory.
/// Inner object path is read-only or is a directory.
/// </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">
/// The specified path is invalid, such as being on an unmapped drive.
Expand All @@ -417,7 +417,7 @@ public interface IFileInfo : IFileSystemInfo
/// </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file is not found.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path"/> is read-only or is a directory.
/// Inner object path is read-only or is a directory.
/// </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">
/// The specified path is invalid, such as being on an unmapped drive.
Expand Down Expand Up @@ -458,15 +458,15 @@ public interface IFileInfo : IFileSystemInfo
/// The name of a file to replace with the current file.
/// </param>
/// <param name="destinationBackupFileName">
/// The name of a file with which to create a backup of the file described by the <paramref name="destFileName"/>
/// The name of a file with which to create a backup of the file described by the <paramref name="destinationFileName"/>
/// parameter.
/// </param>
/// <exception cref="T:System.ArgumentException">
/// The path described by the <paramref name="destFileName"/> parameter was not of a legal form.-or-
/// The path described by the <paramref name="destBackupFileName"/> parameter was not of a legal form.
/// The path described by the <paramref name="destinationFileName"/> parameter was not of a legal form.-or-
/// The path described by the <paramref name="destinationBackupFileName"/> parameter was not of a legal form.
/// </exception>
/// <exception cref="T:System.ArgumentNullException">
/// The <paramref name="destFileName"/> parameter is null.
/// The <paramref name="destinationFileName"/> parameter is null.
/// </exception>
/// <exception cref="T:System.IO.FileNotFoundException">
/// The file described by the current <see cref="T:Rothko.IFileInfo"/> object could not be found.-or-
Expand Down Expand Up @@ -494,19 +494,19 @@ public interface IFileInfo : IFileSystemInfo
/// The name of a file to replace with the current file.
/// </param>
/// <param name="destinationBackupFileName">
/// The name of a file with which to create a backup of the file described by the <paramref name="destFileName"/>
/// The name of a file with which to create a backup of the file described by the <paramref name="destinationFileName"/>
/// parameter.
/// </param>
/// <param name="ignoreMetadataErrors">
/// true to ignore merge errors (such as attributes and ACLs) from the replaced file to the replacement
/// file; otherwise false.
/// </param>
/// <exception cref="T:System.ArgumentException">
/// The path described by the <paramref name="destFileName"/> parameter was not of a legal form.-or-
/// The path described by the <paramref name="destBackupFileName"/> parameter was not of a legal form.
/// The path described by the <paramref name="destinationFileName"/> parameter was not of a legal form.-or-
/// The path described by the <paramref name="destinationBackupFileName"/> parameter was not of a legal form.
/// </exception>
/// <exception cref="T:System.ArgumentNullException">
/// The <paramref name="destFileName"/> parameter is null.
/// The <paramref name="destinationFileName"/> parameter is null.
/// </exception>
/// <exception cref="T:System.IO.FileNotFoundException">
/// The file described by the current <see cref="T:Rothko.IFileInfo"/> object could not be found.-or-
Expand Down
24 changes: 10 additions & 14 deletions src/Infrastructure/IFileSystemFacade.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Rothko
{
Expand All @@ -20,7 +16,7 @@ public interface IFileSystemFacade
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path"/> is a zero-length string, contains only white space, or contains one or
/// more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars"/>.
/// more invalid characters as defined by <see cref="F:System.IO.Path.GetInvalidFileNameChars"/>.
/// -or-<paramref name="path"/> is prefixed with, or contains only a colon character (:).
/// </exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="path"/> is null.</exception>
Expand Down Expand Up @@ -60,7 +56,7 @@ public interface IFileSystemFacade
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path"/> is a zero-length string, contains only white space, or contains one
/// or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars"/>.
/// or more invalid characters as defined by <see cref="F:System.IO.Path.GetInvalidFileNameChars"/>.
/// </exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="path"/> is null.</exception>
/// <exception cref="T:System.IO.PathTooLongException">
Expand Down Expand Up @@ -101,7 +97,7 @@ public interface IFileSystemFacade
/// </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path"/> is a zero-length string, contains only white space, or contains one or
/// more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars"/>.
/// more invalid characters as defined by <see cref="F:System.IO.Path.GetInvalidFileNameChars"/>.
/// </exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="path"/> is null.</exception>
/// <exception cref="T:System.IO.PathTooLongException">
Expand All @@ -121,12 +117,12 @@ public interface IFileSystemFacade
void DeleteDirectory(string path, bool recursive);

/// <summary>Determines whether the given path refers to an existing directory on disk.</summary>
/// <returns>true if <paramref name="path"/> refers to an existing directory; otherwise, false.</returns>
/// <param name="path">The path to test.</param>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
/// </PermissionSet>
/// <returns>true if <paramref name="path"/> refers to an existing directory; otherwise, false.</returns>
/// <param name="path">The path to test.</param>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
/// </PermissionSet>
bool DirectoryExists(string path);

/// <summary>Gets a <see cref="T:Rothko.IDirectoryInfo"/> representing the specified path.</summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Infrastructure/IOperatingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public interface IOperatingSystem : ICloneable, ISerializable
string ServicePack { get; }
Version Version { get; }
string VersionString { get; }
string Name { get; }
string Edition { get; }
}
}
6 changes: 3 additions & 3 deletions src/Infrastructure/IRegistryKey.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Security.AccessControl;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;

namespace Rothko
{
Expand Down
Loading

0 comments on commit e268287

Please sign in to comment.