Make some classes internal + chnage some files to file-scoped namespaces

This commit is contained in:
Stef Heyenrath
2023-03-22 21:57:23 +01:00
parent 9dea577da1
commit 651486f718
8 changed files with 499 additions and 505 deletions
@@ -1,7 +1,7 @@
using System;
using System;
namespace WireMock.Exceptions;
namespace WireMock.Exceptions
{
/// <summary>
/// WireMockException
/// </summary>
@@ -32,4 +32,3 @@ namespace WireMock.Exceptions
{
}
}
}
@@ -3,8 +3,8 @@ using System.IO;
using WireMock.Util;
using Stef.Validation;
namespace WireMock.Handlers
{
namespace WireMock.Handlers;
/// <summary>
/// Default implementation for a handler to interact with the local file system to read and write static mapping files.
/// </summary>
@@ -34,7 +34,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.FolderExists"/>
public virtual bool FolderExists(string path)
{
Guard.NotNullOrEmpty(path, nameof(path));
Guard.NotNullOrEmpty(path);
return Directory.Exists(path);
}
@@ -42,7 +42,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.CreateFolder"/>
public virtual void CreateFolder(string path)
{
Guard.NotNullOrEmpty(path, nameof(path));
Guard.NotNullOrEmpty(path);
Directory.CreateDirectory(path);
}
@@ -50,7 +50,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.EnumerateFiles"/>
public virtual IEnumerable<string> EnumerateFiles(string path, bool includeSubdirectories)
{
Guard.NotNullOrEmpty(path, nameof(path));
Guard.NotNullOrEmpty(path);
return includeSubdirectories ? Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) : Directory.EnumerateFiles(path);
}
@@ -64,7 +64,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.ReadMappingFile"/>
public virtual string ReadMappingFile(string path)
{
Guard.NotNullOrEmpty(path, nameof(path));
Guard.NotNullOrEmpty(path);
return File.ReadAllText(path);
}
@@ -81,7 +81,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsFile"/>
public virtual byte[] ReadResponseBodyAsFile(string path)
{
Guard.NotNullOrEmpty(path, nameof(path));
Guard.NotNullOrEmpty(path);
path = PathUtils.CleanPath(path);
// If the file exists at the given path relative to the MappingsFolder, then return that.
// Else the path will just be as-is.
@@ -91,7 +91,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsString"/>
public virtual string ReadResponseBodyAsString(string path)
{
Guard.NotNullOrEmpty(path, nameof(path));
Guard.NotNullOrEmpty(path);
path = PathUtils.CleanPath(path);
// In case the path is a filename, the path will be adjusted to the MappingFolder.
// Else the path will just be as-is.
@@ -101,7 +101,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.FileExists"/>
public virtual bool FileExists(string filename)
{
Guard.NotNullOrEmpty(filename, nameof(filename));
Guard.NotNullOrEmpty(filename);
return File.Exists(AdjustPathForMappingFolder(filename));
}
@@ -109,8 +109,8 @@ namespace WireMock.Handlers
/// <inheritdoc />
public virtual void WriteFile(string filename, byte[] bytes)
{
Guard.NotNullOrEmpty(filename, nameof(filename));
Guard.NotNull(bytes, nameof(bytes));
Guard.NotNullOrEmpty(filename);
Guard.NotNull(bytes);
File.WriteAllBytes(AdjustPathForMappingFolder(filename), bytes);
}
@@ -128,7 +128,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.DeleteFile"/>
public virtual void DeleteFile(string filename)
{
Guard.NotNullOrEmpty(filename, nameof(filename));
Guard.NotNullOrEmpty(filename);
File.Delete(AdjustPathForMappingFolder(filename));
}
@@ -136,7 +136,7 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.ReadFile"/>
public virtual byte[] ReadFile(string filename)
{
Guard.NotNullOrEmpty(filename, nameof(filename));
Guard.NotNullOrEmpty(filename);
return File.ReadAllBytes(AdjustPathForMappingFolder(filename));
}
@@ -156,8 +156,8 @@ namespace WireMock.Handlers
/// <inheritdoc cref="IFileSystemHandler.WriteUnmatchedRequest"/>
public virtual void WriteUnmatchedRequest(string filename, string text)
{
Guard.NotNullOrEmpty(filename, nameof(filename));
Guard.NotNull(text, nameof(text));
Guard.NotNullOrEmpty(filename);
Guard.NotNull(text);
var folder = GetUnmatchedRequestsFolder();
if (!FolderExists(folder))
@@ -178,4 +178,3 @@ namespace WireMock.Handlers
return Path.Combine(GetMappingFolder(), filename);
}
}
}
@@ -1,6 +1,5 @@
using System.Net.Http.Headers;
using AnyOfTypes;
using JetBrains.Annotations;
using WireMock.Models;
namespace WireMock.Matchers;
+2 -3
View File
@@ -1,7 +1,7 @@
using System;
namespace WireMock.Models
{
namespace WireMock.Models;
/// <summary>
/// TimeSettingsModel: Start, End and TTL
/// </summary>
@@ -16,4 +16,3 @@ namespace WireMock.Models
/// <inheritdoc />
public int? TTL { get; set; }
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace WireMock.Util;
/// http://www.unicode.org/versions/corrigendum1.html
/// http://www.ietf.org/rfc/rfc2279.txt
/// </summary>
public static class BytesEncodingUtils
internal static class BytesEncodingUtils
{
/// <summary>
/// Tries the get the Encoding from an array of bytes.
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace WireMock.Util
{
namespace WireMock.Util;
/// <summary>
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe.
/// </summary>
@@ -83,4 +83,3 @@ namespace WireMock.Util
}
}
}
}
@@ -4,8 +4,8 @@ using System.IO;
using JetBrains.Annotations;
using Stef.Validation;
namespace WireMock.Util
{
namespace WireMock.Util;
/// <summary>
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
/// </summary>
@@ -251,4 +251,3 @@ namespace WireMock.Util
#endregion
#endregion
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ namespace WireMock.Util;
/// <summary>
/// Port Utility class
/// </summary>
public static class PortUtils
internal static class PortUtils
{
private static readonly Regex UrlDetailsRegex = new(@"^((?<proto>\w+)://)(?<host>[^/]+?):(?<port>\d+)\/?$", RegexOptions.Compiled);