Skip to content

Commit

Permalink
* Copied the ExceptionShieldingErrorHandler from Enterprise Library a…
Browse files Browse the repository at this point in the history
…nd modified to set the `HttpStatusCode`.

            For faults that inherit from `vm.Aspects.Wcf.FaultContract.Fault` it takes the code from the fault property `HttpStatusCode`,
            for all others - sets the error code to HTTP 500 - internal server error.
            * Added the property `HttpStatusCode` to the base class
            * Removed the dependency on the NuGet package Microsoft.Practices.EnterpriseLibrary.PolicyInjection which depended on Unity 3.0.
            Recompiled and added Microsoft.Practices.EnterpriseLibrary.PolicyInjection as a standalone assembly depending on Unity 4.0.1.
             * In vm.Aspects.Diagnostics.ObjectDumper added contracts to the internal DumpTextWriter.
  • Loading branch information
vmelamed committed Jan 27, 2016
1 parent abde052 commit 9dbd0e1
Show file tree
Hide file tree
Showing 53 changed files with 1,892 additions and 123 deletions.
29 changes: 11 additions & 18 deletions Aspects/Diagnostics/DumpImplementation/DumpTextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class DumpTextWriter : TextWriter
// the default maximum length of the dump
public const int DefaultMaxLength = 4 * 1024 * 1024;

bool _isClosed;
readonly StringWriter _writer;
readonly bool _isOwnWriter;
int _indent;
Expand Down Expand Up @@ -48,7 +47,7 @@ public DumpTextWriter(
_maxLength = maxLength;
}

[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification="N/A")]
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "N/A")]
public DumpTextWriter(
StringBuilder existing,
int maxLength = 0)
Expand Down Expand Up @@ -95,9 +94,11 @@ public int IndentSize
set { _indentSize = value < 0 ? 0 : value; }
}

public bool IsClosed { get; private set; }

public override void Close()
{
_isClosed = true;
IsClosed = true;
_writer.Close();
}

Expand All @@ -106,34 +107,26 @@ public override void Write(string value)
if (string.IsNullOrEmpty(value))
return;

if (_isClosed)
throw new InvalidOperationException("The writer is closed.");

WriteCharBuffer(value.ToCharArray(), 0, value.Length);
}

public override void Write(char value)
{
if (_isClosed)
throw new InvalidOperationException("The writer is closed.");

WriteChar(value);
}

[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId="0")]
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
public override void Write(
char[] buffer,
int index,
int count)
{
if (_isClosed)
throw new InvalidOperationException("The writer is closed.");

WriteCharBuffer(buffer, index, count);
}

void WriteCharBuffer(char[] buffer, int index, int count)
{
Contract.Requires<InvalidOperationException>(!IsClosed, "The writer is closed.");
Contract.Requires(buffer != null, "buffer");
Contract.Requires(index >= 0, "The parameter index must be non-negative.");
Contract.Requires(count >= 0, "The parameter count must be non-negative.");
Expand All @@ -159,10 +152,10 @@ void WriteChar(char value)
_mustIndent = true;
else
if (_mustIndent && value != '\r') // we don't want to insert indentation blank strings on empty lines
{
_writer.Write(GetIndent());
_mustIndent = false;
}
{
_writer.Write(GetIndent());
_mustIndent = false;
}

_writer.Write(value);
}
Expand All @@ -179,7 +172,7 @@ string GetIndent()

protected override void Dispose(bool disposing)
{
_isClosed = true;
IsClosed = true;
if (disposing && _isOwnWriter)
_writer.Dispose();
base.Dispose(disposing);
Expand Down
4 changes: 2 additions & 2 deletions Aspects/Diagnostics/NuGet/ObjectDumper.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>AspectObjectDumper</id>
<version>1.5.1</version>
<version>1.5.2</version>
<authors>Val Melamed</authors>
<owners>Val Melamed</owners>
<summary>
Expand All @@ -28,7 +28,7 @@
* Build and tested with .NET 4.0, 4.6. This package targets .NET 4.0.
</description>
<releaseNotes>
Fixing the dependencies.
Added contracts to the internal DumpTextWriter.
</releaseNotes>
<licenseUrl>https://aspectobjectdumper.codeplex.com/license</licenseUrl>
<projectUrl>https://aspectobjectdumper.codeplex.com/</projectUrl>
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Diagnostics/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: AssemblyTitle("vm.Aspects.Diagnostics.ObjectDumper")]
[assembly: AssemblyDescription("Dumps the properties' and fields' values of any .NET object in a text form.")]
[assembly: AssemblyVersion("1.5.1")]
[assembly: AssemblyFileVersion("1.5.1")]
[assembly: AssemblyInformationalVersion("1.5.1")]
[assembly: AssemblyVersion("1.5.2")]
[assembly: AssemblyFileVersion("1.5.2")]
[assembly: AssemblyInformationalVersion("1.5.2")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Diagnostics.ObjectDumper.Tests, " +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using vm.Aspects.Diagnostics.DumpImplementation;

Expand Down Expand Up @@ -50,8 +48,14 @@ public void WriteBufferNull()
w.Write(new char[] { 'a', 'b', 'c' }, -1, -2);
Assert.Fail("Expected System.Diagnostics.Contracts.__ContractsRuntime+ContractException");
}
catch (AssertFailedException x)
{
TestContext.WriteLine(x.DumpString());
throw;
}
catch (Exception x)
{
TestContext.WriteLine(x.DumpString());
Assert.AreEqual("System.Diagnostics.Contracts.__ContractsRuntime+ContractException", x.GetType().FullName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>AspectExpressionSerialization</id>
<version>1.0.33</version>
<version>1.0.34</version>
<authors>Val Melamed</authors>
<owners>Val Melamed</owners>
<summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[assembly: AssemblyTitle("vm.Aspects.Linq.Expressions.Serialization")]
[assembly: AssemblyDescription("Serializes and deserializes LINQ expression trees to and from XML documents.")]

[assembly: AssemblyVersion("1.0.33")]
[assembly: AssemblyFileVersion("1.0.33")]
[assembly: AssemblyInformationalVersion("1.0.33")]
[assembly: AssemblyVersion("1.0.34")]
[assembly: AssemblyFileVersion("1.0.34")]
[assembly: AssemblyInformationalVersion("1.0.34")]

[assembly: InternalsVisibleTo(
"vm.Aspects.Linq.Expressions.Serialization.Test, " +
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Model/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[assembly: AssemblyTitle("vm.Aspect.Model")]
[assembly: AssemblyDescription("Defines the IRepository and related base classes and utilities - a framework of building domain object model.")]

[assembly: AssemblyVersion("1.0.33")]
[assembly: AssemblyFileVersion("1.0.33")]
[assembly: AssemblyInformationalVersion("1.0.33")]
[assembly: AssemblyVersion("1.0.34")]
[assembly: AssemblyFileVersion("1.0.34")]
[assembly: AssemblyInformationalVersion("1.0.34")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Model.Tests, " +
Expand Down
3 changes: 1 addition & 2 deletions Aspects/Model/Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AspectObjectDumper" version="1.5.1" targetFramework="net46" />
<package id="AspectObjectDumper" version="1.5.2" targetFramework="net46" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net46" />
<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net46" />
<package id="EnterpriseLibrary.Logging" version="6.0.1304.0" targetFramework="net46" />
<package id="EnterpriseLibrary.PolicyInjection" version="6.0.1304.0" targetFramework="net46" />
<package id="EnterpriseLibrary.Validation" version="6.0.1304.0" targetFramework="net46" />
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
<package id="Unity" version="4.0.1" targetFramework="net46" />
Expand Down
8 changes: 4 additions & 4 deletions Aspects/Model/Tests/vm.Aspects.Model.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\EnterpriseLibrary.PolicyInjection.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll</HintPath>
<Private>True</Private>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Externals\Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.EnterpriseLibrary.Validation, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\EnterpriseLibrary.Validation.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.Validation.dll</HintPath>
Expand Down Expand Up @@ -234,8 +234,8 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Transactions" />
<Reference Include="vm.Aspects.Diagnostics.ObjectDumper, Version=1.5.1.0, Culture=neutral, PublicKeyToken=39c66c470a75c367, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\AspectObjectDumper.1.5.1\lib\net40\vm.Aspects.Diagnostics.ObjectDumper.dll</HintPath>
<Reference Include="vm.Aspects.Diagnostics.ObjectDumper, Version=1.5.2.0, Culture=neutral, PublicKeyToken=39c66c470a75c367, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\AspectObjectDumper.1.5.2\lib\net40\vm.Aspects.Diagnostics.ObjectDumper.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Aspects/Model/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AspectObjectDumper" version="1.5.1" targetFramework="net46" />
<package id="AspectObjectDumper" version="1.5.2" targetFramework="net46" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net46" />
<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net46" />
<package id="EnterpriseLibrary.ExceptionHandling" version="6.0.1304.0" targetFramework="net46" />
Expand Down
4 changes: 2 additions & 2 deletions Aspects/Model/vm.Aspects.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="vm.Aspects.Diagnostics.ObjectDumper, Version=1.5.1.0, Culture=neutral, PublicKeyToken=39c66c470a75c367, processorArchitecture=MSIL">
<HintPath>..\..\packages\AspectObjectDumper.1.5.1\lib\net40\vm.Aspects.Diagnostics.ObjectDumper.dll</HintPath>
<Reference Include="vm.Aspects.Diagnostics.ObjectDumper, Version=1.5.2.0, Culture=neutral, PublicKeyToken=39c66c470a75c367, processorArchitecture=MSIL">
<HintPath>..\..\packages\AspectObjectDumper.1.5.2\lib\net40\vm.Aspects.Diagnostics.ObjectDumper.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
16 changes: 11 additions & 5 deletions Aspects/NuGet/vm.Aspects.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>vm.Aspects</id>
<version>1.0.33-beta</version>
<version>1.0.34-beta</version>
<authors>Val Melamed</authors>
<owners>Val Melamed</owners>
<summary>
Expand All @@ -12,8 +12,12 @@
A set of classes, utilities, etc. addressing various common cross-cutting concerns or extending existing similar libraries like Enterprise Library, Unity, etc.
</description>
<releaseNotes>
Fixing the dependencies.
Improvement in vm.Aspects.Model.EFRepository.EFSpecifics.IsChangeTracking method.
* Copied the ExceptionShieldingErrorHandler from Enterprise Library and modified to set the `HttpStatusCode`.
For faults that inherit from `vm.Aspects.Wcf.FaultContract.Fault` it takes the code from the fault property `HttpStatusCode`,
for all others - sets the error code to HTTP 500 - internal server error.
* Added the property `HttpStatusCode` to the base class
* Removed the dependency on the NuGet package Microsoft.Practices.EnterpriseLibrary.PolicyInjection which depended on Unity 3.0.
Recompiled and added Microsoft.Practices.EnterpriseLibrary.PolicyInjection as a standalone assembly depending on Unity 4.0.1.
</releaseNotes>
<licenseUrl>https://github.com/vmelamed/vm/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/vmelamed/vm/tree/master/Aspects</projectUrl>
Expand All @@ -40,8 +44,6 @@
version="6.0.1304.0" />
<dependency id="EnterpriseLibrary.Validation"
version="6.0.1304.0" />
<dependency id="EnterpriseLibrary.PolicyInjection"
version="6.0.1304.0" />

<dependency id="EntityFramework"
version="6.1.3" />
Expand All @@ -68,5 +70,9 @@
target="lib\net46"/>
<file src="..\Parsers\bin\Release\vm.Aspects.Parsers.xml"
target="lib\net46"/>
<file src="..\bin\Release\Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll"
target="lib\net46"/>
<file src="..\bin\Release\Microsoft.Practices.EnterpriseLibrary.PolicyInjection.xml"
target="lib\net46"/>
</files>
</package>
6 changes: 3 additions & 3 deletions Aspects/Parsers/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[assembly: AssemblyTitle("vm.Aspects.Parser")]
[assembly: AssemblyDescription("Text parsing readers, e.g. CSV/TSV reader.")]

[assembly: AssemblyVersion("1.0.33")]
[assembly: AssemblyFileVersion("1.0.33")]
[assembly: AssemblyInformationalVersion("1.0.33")]
[assembly: AssemblyVersion("1.0.34")]
[assembly: AssemblyFileVersion("1.0.34")]
[assembly: AssemblyInformationalVersion("1.0.34")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Parsers.Tests, " +
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: AssemblyTitle("vm.Aspects")]
[assembly: AssemblyDescription("A set of classes addressing various common cross-cutting concerns.")]
[assembly: AssemblyVersion("1.0.33")]
[assembly: AssemblyFileVersion("1.0.33")]
[assembly: AssemblyInformationalVersion("1.0.33")]
[assembly: AssemblyVersion("1.0.34")]
[assembly: AssemblyFileVersion("1.0.34")]
[assembly: AssemblyInformationalVersion("1.0.34")]


[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
Expand Down
17 changes: 15 additions & 2 deletions Aspects/RegularExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,21 @@ public static class RegularExpression
public static Regex SemanticVersion => _semanticVersion.Value;
#endregion

#region Misceleaneous
#region Guid
/// <summary>
/// Regular expression pattern which matches ...
/// </summary>
public const string RexGuid = @"(?i:^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|(?:[0-9a-f]{32})$)";

readonly static Lazy<Regex> _rexGuid = new Lazy<Regex>(() => new Regex(RexGuid, RegexOptions.Compiled));

/// <summary>
/// Gets a Regex object which matches ...
/// </summary>
public static Regex Guid => _rexGuid.Value;
#endregion


#region ByteArray
/// <summary>
/// Matches a text representation of a byte array the way it is produces by BitConverter,
Expand Down Expand Up @@ -618,7 +632,6 @@ public static class RegularExpression
/// </summary>
public static Regex CSharpIdentifier => _cSharpIdentifier.Value;
#endregion
#endregion

/// <summary>
/// Dumps all regular expressions in this class.
Expand Down
Loading

0 comments on commit 9dbd0e1

Please sign in to comment.