Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tathamoddie/System.IO.Abstractions
base: 7aed17bb1e
...
head fork: tathamoddie/System.IO.Abstractions
compare: 3c64e7e069
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 26, 2014
@manne manne code cleanup 3bd23a8
Commits on Mar 02, 2014
@tathamoddie Merge pull request #63 from manne/cleanup
code cleanup
3c64e7e
View
2  System.IO.Abstractions/Converters.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
namespace System.IO.Abstractions
@@ -17,6 +18,7 @@ internal static FileSystemInfoBase[] WrapFileSystemInfos(this IEnumerable<FileSy
return (DirectoryInfoBase) item;
throw new NotImplementedException(string.Format(
+ CultureInfo.InvariantCulture,
"The type {0} is not recognized by the System.IO.Abstractions library.",
item.GetType().AssemblyQualifiedName
));
View
7 System.IO.Abstractions/FileSystemWatcherWrapper.cs
@@ -1,14 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
+using System.ComponentModel;
namespace System.IO.Abstractions
{
[Serializable]
public class FileSystemWatcherWrapper : FileSystemWatcherBase
{
+ [NonSerialized]
private readonly FileSystemWatcher watcher;
public FileSystemWatcherWrapper()
View
2  TestHelpers.Tests/FileSystemTests.cs
@@ -14,7 +14,7 @@ public void Is_Serializable()
var serializer = new Runtime.Serialization.Formatters.Binary.BinaryFormatter();
serializer.Serialize(memoryStream, fileSystem);
- Assert.That(memoryStream.Length > 0, "Length didnt increase after serialization task.");
+ Assert.That(memoryStream.Length > 0, "Length didn't increase after serialization task.");
}
}
}
View
2  TestHelpers.Tests/MockFileSystemTests.cs
@@ -90,7 +90,7 @@ public void Is_Serializable()
var serializer = new Runtime.Serialization.Formatters.Binary.BinaryFormatter();
serializer.Serialize(memoryStream, fileSystem);
- Assert.That(memoryStream.Length > 0, "Length didnt increase after serialization task.");
+ Assert.That(memoryStream.Length > 0, "Length didn't increase after serialization task.");
}
}
}
View
7 TestHelpers.Tests/MockFileTests.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
using NUnit.Framework;
@@ -73,10 +74,10 @@ public void MockFile_AppendAllText_ShouldFailIfNotExistButDirectoryAlsoNotExist(
// Assert
Exception ex;
ex = Assert.Throws<DirectoryNotFoundException>(() => fileSystem.File.AppendAllText(path, "some text"));
- Assert.That(ex.Message, Is.EqualTo(String.Format("Could not find a part of the path '{0}'.", path)));
+ Assert.That(ex.Message, Is.EqualTo(String.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path)));
ex = Assert.Throws<DirectoryNotFoundException>(() => fileSystem.File.AppendAllText(path, "some text", Encoding.Unicode));
- Assert.That(ex.Message, Is.EqualTo(String.Format("Could not find a part of the path '{0}'.", path)));
+ Assert.That(ex.Message, Is.EqualTo(String.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path)));
}
[Test]
@@ -1012,7 +1013,7 @@ public void Mockfile_Create_ThrowsWhenPathIsReadOnly()
mockFile.SetAttributes(path, FileAttributes.ReadOnly);
var exception = Assert.Throws<UnauthorizedAccessException>(() => mockFile.Create(path).Close());
- Assert.That(exception.Message, Is.EqualTo(string.Format("Access to the path '{0}' is denied.", path)));
+ Assert.That(exception.Message, Is.EqualTo(string.Format(CultureInfo.InvariantCulture, "Access to the path '{0}' is denied.", path)));
}
[Test]
View
11 TestingHelpers/MockDirectory.cs
@@ -50,7 +50,7 @@ public override void Delete(string path, bool recursive)
path = EnsurePathEndsWithDirectorySeparator(mockFileDataAccessor.Path.GetFullPath(path));
var affectedPaths = mockFileDataAccessor
.AllPaths
- .Where(p => p.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
+ .Where(p => p.StartsWith(path, StringComparison.OrdinalIgnoreCase))
.ToList();
if (!affectedPaths.Any())
@@ -69,7 +69,7 @@ public override bool Exists(string path)
path = EnsurePathEndsWithDirectorySeparator(path);
path = mockFileDataAccessor.Path.GetFullPath(path);
- return mockFileDataAccessor.AllDirectories.Any(p => p.Equals(path, StringComparison.InvariantCultureIgnoreCase));
+ return mockFileDataAccessor.AllDirectories.Any(p => p.Equals(path, StringComparison.OrdinalIgnoreCase));
}
public override DirectorySecurity GetAccessControl(string path)
@@ -113,7 +113,7 @@ public override string[] GetDirectories(string path, string searchPattern, Searc
if (!Exists(path))
{
- throw new DirectoryNotFoundException(string.Format("Could not find a part of the path '{0}'.", path));
+ throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
}
var dirs = GetFilesInternal(mockFileDataAccessor.AllDirectories, path, searchPattern, searchOption);
@@ -141,7 +141,7 @@ public override string[] GetFiles(string path, string searchPattern, SearchOptio
{
if (!Exists(path))
{
- throw new DirectoryNotFoundException(string.Format("Could not find a part of the path '{0}'.", path));
+ throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
}
return GetFilesInternal(mockFileDataAccessor.AllFiles, path, searchPattern, searchOption);
@@ -162,6 +162,7 @@ private string[] GetFilesInternal(IEnumerable<string> files, string path, string
.Replace(@"\?", @"[^<>:""/\\|?*]?");
var pathPattern = string.Format(
+ CultureInfo.InvariantCulture,
@"(?i:^{0}{1}{2}$)",
Regex.Escape(path),
searchOption == SearchOption.AllDirectories ? allDirectoriesPattern : string.Empty,
@@ -290,7 +291,7 @@ public override void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc)
static string EnsurePathEndsWithDirectorySeparator(string path)
{
- if (!path.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
+ if (!path.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
path += Path.DirectorySeparatorChar;
return path;
}
View
4 TestingHelpers/MockDirectoryInfo.cs
@@ -11,8 +11,8 @@ public class MockDirectoryInfo : DirectoryInfoBase
readonly IMockFileDataAccessor mockFileDataAccessor;
readonly string directoryPath;
- private string EnsurePathEndsWithDirectorySeparator(string directoryPath) {
- if (!directoryPath.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture)))
+ private static string EnsurePathEndsWithDirectorySeparator(string directoryPath) {
+ if (!directoryPath.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
directoryPath += Path.DirectorySeparatorChar;
return directoryPath;
}
View
17 TestingHelpers/MockFile.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using System.Globalization;
using System.Security.AccessControl;
using System.Text;
@@ -23,7 +24,7 @@ public override void AppendAllText(string path, string contents)
var dir = mockFileDataAccessor.Path.GetDirectoryName(path);
if (!mockFileDataAccessor.Directory.Exists(dir))
{
- throw new DirectoryNotFoundException(String.Format("Could not find a part of the path '{0}'.", path));
+ throw new DirectoryNotFoundException(String.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
}
mockFileDataAccessor.AddFile(path, new MockFileData(contents));
}
@@ -42,7 +43,7 @@ public override void AppendAllText(string path, string contents, Encoding encodi
var dir = mockFileDataAccessor.Path.GetDirectoryName(path);
if (!mockFileDataAccessor.Directory.Exists(dir))
{
- throw new DirectoryNotFoundException(String.Format("Could not find a part of the path '{0}'.", path));
+ throw new DirectoryNotFoundException(String.Format(CultureInfo.InvariantCulture, "Could not find a part of the path '{0}'.", path));
}
mockFileDataAccessor.AddFile(path, new MockFileData(encoding.GetBytes(contents)));
}
@@ -73,7 +74,7 @@ public override StreamWriter AppendText(string path)
public override void Copy(string sourceFileName, string destFileName)
{
if (mockFileDataAccessor.FileExists(destFileName))
- throw new IOException(string.Format("The file {0} already exists.", destFileName));
+ throw new IOException(string.Format(CultureInfo.InvariantCulture, "The file {0} already exists.", destFileName));
mockFileDataAccessor.AddFile(destFileName, mockFileDataAccessor.GetFile(sourceFileName));
}
@@ -195,7 +196,7 @@ public override DateTime GetLastWriteTimeUtc(string path)
var sourceFile = mockFileDataAccessor.GetFile(sourceFileName);
if (sourceFile == null)
- throw new FileNotFoundException(string.Format("The file \"{0}\" could not be found.", sourceFileName), sourceFileName);
+ throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "The file \"{0}\" could not be found.", sourceFileName), sourceFileName);
mockFileDataAccessor.AddFile(destFileName, new MockFileData(sourceFile.Contents));
mockFileDataAccessor.RemoveFile(sourceFileName);
@@ -218,7 +219,7 @@ public override Stream Open(string path, FileMode mode)
bool exists = mockFileDataAccessor.FileExists(path);
if (mode == FileMode.CreateNew && exists)
- throw new IOException(string.Format("The file '{0}' already exists.", path));
+ throw new IOException(string.Format(CultureInfo.InvariantCulture, "The file '{0}' already exists.", path));
if ((mode == FileMode.Open || mode == FileMode.Truncate) && !exists)
throw new FileNotFoundException(path);
@@ -278,7 +279,7 @@ public override byte[] ReadAllBytes(string path)
public override string[] ReadAllLines(string path)
{
if (!mockFileDataAccessor.FileExists(path))
- throw new FileNotFoundException(string.Format("Can't find {0}", path));
+ throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "Can't find {0}", path));
return mockFileDataAccessor
.GetFile(path)
.TextContents
@@ -288,7 +289,7 @@ public override string[] ReadAllLines(string path)
public override string[] ReadAllLines(string path, Encoding encoding)
{
if (!mockFileDataAccessor.FileExists(path))
- throw new FileNotFoundException(string.Format("Can't find {0}", path));
+ throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "Can't find {0}", path));
return encoding
.GetString(mockFileDataAccessor.GetFile(path).Contents)
.SplitLines();
@@ -297,7 +298,7 @@ public override string[] ReadAllLines(string path, Encoding encoding)
public override string ReadAllText(string path)
{
if (!mockFileDataAccessor.FileExists(path))
- throw new FileNotFoundException(string.Format("Can't find {0}", path));
+ throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "Can't find {0}", path));
return mockFileDataAccessor.GetFile(path).TextContents;
}
View
3  TestingHelpers/MockFileData.cs
@@ -6,7 +6,8 @@ namespace System.IO.Abstractions.TestingHelpers
public class MockFileData
{
static readonly Encoding defaultEncoding = Encoding.UTF8;
- public static readonly MockFileData NullObject = new MockFileData("") {
+
+ public static readonly MockFileData NullObject = new MockFileData(string.Empty) {
LastWriteTime = new DateTime(1601, 01, 01, 00, 00, 00, DateTimeKind.Utc),
LastAccessTime = new DateTime(1601, 01, 01, 00, 00, 00, DateTimeKind.Utc),
CreationTime = new DateTime(1601, 01, 01, 00, 00, 00, DateTimeKind.Utc),
View
7 TestingHelpers/MockFileSystem.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
namespace System.IO.Abstractions.TestingHelpers
@@ -17,7 +18,7 @@ public class MockFileSystem : IFileSystem, IMockFileDataAccessor
public MockFileSystem(IDictionary<string, MockFileData> files, string currentDirectory = @"C:\Foo\Bar")
{
- this.files = new Dictionary<string, MockFileData>(StringComparer.InvariantCultureIgnoreCase);
+ this.files = new Dictionary<string, MockFileData>(StringComparer.OrdinalIgnoreCase);
pathField = new MockPath(this);
file = new MockFile(this);
directory = new MockDirectory(this, file, FixPath(currentDirectory));
@@ -72,7 +73,7 @@ public void AddFile(string path, MockFileData mockFile)
{
var fixedPath = FixPath(path);
if (FileExists(fixedPath) && (files[fixedPath].Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
- throw new UnauthorizedAccessException(string.Format("Access to the path '{0}' is denied.", path));
+ throw new UnauthorizedAccessException(string.Format(CultureInfo.InvariantCulture, "Access to the path '{0}' is denied.", path));
var directoryPath = Path.GetDirectoryName(fixedPath);
@@ -93,7 +94,7 @@ public void AddDirectory(string path)
{
if (FileExists(path) &&
(files[fixedPath].Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
- throw new UnauthorizedAccessException(string.Format("Access to the path '{0}' is denied.", path));
+ throw new UnauthorizedAccessException(string.Format(CultureInfo.InvariantCulture, "Access to the path '{0}' is denied.", path));
files[fixedPath] = new MockDirectoryData();
}

No commit comments for this range

Something went wrong with that request. Please try again.