Skip to content

Commit

Permalink
Published vm.Aspects 1.0.51 and ObjectDumper 1.5.5 on NuGet
Browse files Browse the repository at this point in the history
  • Loading branch information
vmelamed committed Apr 26, 2016
1 parent f6d20de commit 5056bbd
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.IO;
using System.Net;

Expand All @@ -9,16 +11,19 @@ public abstract class WebExceptionDumpMetadata
{
/// <remarks/>
[Dump(0)]
public object Status;
public object Status { get; set; }

/// <remarks/>
[Dump(1, DumpClass = typeof(WebExceptionDumpMetadata), DumpMethod = nameof(DumpResponse))]
public object Response;
public object Response { get; set; }

/// <remarks/>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public static string DumpResponse(
WebResponse response)
{
Contract.Ensures(Contract.Result<string>() != null);

var stream = response?.GetResponseStream();

if (stream == null)
Expand Down
2 changes: 1 addition & 1 deletion Aspects/Diagnostics/NuGet/PublishObjectDumper.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if not exist c:\NuGet md c:\NuGet
copy /y *.nupkg c:\NuGet
@echo Press any key to push to NuGet.org... > con:
@pause > nul:
NuGet Push AspectObjectDumper.1.5.5.nupkg -source https://www.nuget.org/api/v2/
NuGet Push AspectObjectDumper.1.5.5.nupkg -source https://www.nuget.org
:exit
popd
pause
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.50</version>
<version>1.0.51</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.50")]
[assembly: AssemblyFileVersion("1.0.50")]
[assembly: AssemblyInformationalVersion("1.0.50")]
[assembly: AssemblyVersion("1.0.51")]
[assembly: AssemblyFileVersion("1.0.51")]
[assembly: AssemblyInformationalVersion("1.0.51")]

[assembly: InternalsVisibleTo(
"vm.Aspects.Linq.Expressions.Serialization.Test, " +
Expand Down
1 change: 1 addition & 0 deletions Aspects/Model/EFRepository/EFRepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ IList<DbValidationError> ToValidationErrors(
/// is by this context or ownership was passed to this context when this context was created.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
[SuppressMessage("Microsoft.Usage", "CA2215:Dispose methods should call base class dispose")]
protected override void Dispose(
bool disposing)
{
Expand Down
3 changes: 2 additions & 1 deletion Aspects/Model/PerCallContextRepositoryCallHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public IMethodReturn Invoke(

#endregion

[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The scope will be disposed in PostInvoke.")]
void PreInvoke(IMethodInvocation input)
{
if (!CreateTransactionScopeForTasks)
Expand All @@ -92,7 +93,7 @@ void PreInvoke(IMethodInvocation input)
input.InvocationContext["transactionScope"] = scope;
}

IMethodReturn DoInvoke(
static IMethodReturn DoInvoke(
IMethodInvocation input,
GetNextHandlerDelegate getNext) => getNext().Invoke(input, getNext);

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.50")]
[assembly: AssemblyFileVersion("1.0.50")]
[assembly: AssemblyInformationalVersion("1.0.50")]
[assembly: AssemblyVersion("1.0.51")]
[assembly: AssemblyFileVersion("1.0.51")]
[assembly: AssemblyInformationalVersion("1.0.51")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Model.Tests, " +
Expand Down
2 changes: 1 addition & 1 deletion Aspects/NuGet/PublishAspects.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if not exist c:\NuGet md c:\NuGet
copy /y *.nupkg c:\NuGet
@echo Press any key to push to NuGet.org... > con:
@pause > nul:
NuGet Push vm.Aspects.1.0.50-beta.nupkg
NuGet Push vm.Aspects.1.0.51-beta.nupkg -source https://www.nuget.org
:exit
popd
pause
2 changes: 1 addition & 1 deletion 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.50-beta</version>
<version>1.0.51-beta</version>
<authors>Val Melamed</authors>
<owners>Val Melamed</owners>
<summary>
Expand Down
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.50")]
[assembly: AssemblyFileVersion("1.0.50")]
[assembly: AssemblyInformationalVersion("1.0.50")]
[assembly: AssemblyVersion("1.0.51")]
[assembly: AssemblyFileVersion("1.0.51")]
[assembly: AssemblyInformationalVersion("1.0.51")]

[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.50")]
[assembly: AssemblyFileVersion("1.0.50")]
[assembly: AssemblyInformationalVersion("1.0.50")]
[assembly: AssemblyVersion("1.0.51")]
[assembly: AssemblyFileVersion("1.0.51")]
[assembly: AssemblyInformationalVersion("1.0.51")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Test, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if not exist c:\NuGet md c:\NuGet
copy /y *.nupkg c:\NuGet
@echo Press any key to push to NuGet.org... > con:
@pause > nul:
NuGet Push Ciphers.1.11.9.nupkg -source https://www.nuget.org/api/v2/
NuGet Push Ciphers.1.11.9.nupkg -source https://www.nuget.org
:exit
popd
pause
70 changes: 69 additions & 1 deletion Aspects/Wcf/AsyncCallContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ namespace vm.Aspects.Wcf
/// Maintains a simple synchronized key-value collection to replace
/// the one from the <see cref="CallContext"/> which is failing in asynchronous situations.
/// </summary>
public class AsyncCallContext
public class AsyncCallContext : IDisposable, IIsDisposed
{
readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
IDictionary<string, object> _contextSlots = new Dictionary<string, object>();

/// <summary>
/// Gets the current asynchronous call context.
/// </summary>
public static AsyncCallContext Current => CallContext.LogicalGetData(nameof(AsyncCallContext)) as AsyncCallContext;

/// <summary>
/// Gets the entry at the data slot with name <paramref name="slotName"/>.
/// </summary>
Expand Down Expand Up @@ -94,5 +99,68 @@ void ObjectInvariant()
{
Contract.Invariant(_contextSlots != null);
}

#region IDisposable pattern implementation
/// <summary>
/// The flag will be set just before the object is disposed.
/// </summary>
/// <value>0 - if the object is not disposed yet, any other value - the object is already disposed.</value>
/// <remarks>
/// Do not test or manipulate this flag outside of the property <see cref="IsDisposed"/> or the method <see cref="Dispose()"/>.
/// The type of this field is Int32 so that it can be easily passed to the members of the class <see cref="Interlocked"/>.
/// </remarks>
int _disposed;

/// <summary>
/// Returns <see langword="true"/> if the object has already been disposed, otherwise <see langword="false"/>.
/// </summary>
public bool IsDisposed => Interlocked.CompareExchange(ref _disposed, 1, 1) == 1;

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <remarks>Invokes the protected virtual <see cref="Dispose(bool)"/>.</remarks>
[SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "It is correct.")]
public void Dispose()
{
// if it is disposed or in a process of disposing - return.
if (Interlocked.Exchange(ref _disposed, 1) != 0)
return;

// these will be called only if the instance is not disposed and is not in a process of disposing.
Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Allows the object to attempt to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
/// </summary>
/// <remarks>Invokes the protected virtual <see cref="Dispose(bool)"/> with parameter <see langword="false"/>.</remarks>
~AsyncCallContext()
{
Dispose(false);
}

/// <summary>
/// Performs the actual job of disposing the object.
/// </summary>
/// <param name="disposing">
/// Passes the information whether this method is called by <see cref="Dispose()"/> (explicitly or
/// implicitly at the end of a <c>using</c> statement), or by the finalizer.
/// </param>
/// <remarks>
/// If the method is called with <paramref name="disposing"/>==<see langword="true"/>, i.e. from <see cref="Dispose()"/>,
/// it will try to release all managed resources (usually aggregated objects which implement <see cref="IDisposable"/> as well)
/// and then it will release all unmanaged resources if any. If the parameter is <see langword="false"/> then
/// the method will only try to release the unmanaged resources.
/// </remarks>
protected virtual void Dispose(bool disposing)
{
if (!disposing)
return;

_lock.Dispose();
}
#endregion
}
}
15 changes: 3 additions & 12 deletions Aspects/Wcf/Behaviors/AsyncCallContextMessageInspector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Messaging;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
Expand Down Expand Up @@ -29,9 +27,6 @@ public object AfterReceiveRequest(

CallContext.LogicalSetData(CallContextSlotName, context);

Trace.WriteLine(
string.Format(CultureInfo.InvariantCulture, "### Installed async context: {0}", context.GetHashCode().ToString()));

return null;
}

Expand All @@ -44,12 +39,10 @@ public void BeforeSendReply(
ref Message reply,
object correlationState)
{
if (!ClearCallContext())
Trace.WriteLine(
string.Format(CultureInfo.InvariantCulture, "*** ASYNC CONTEXT WAS NOT FOUND!"));
ClearCallContext();
}

bool ClearCallContext()
static bool ClearCallContext()
{
var context = CallContext.LogicalGetData(CallContextSlotName) as AsyncCallContext;

Expand All @@ -58,8 +51,6 @@ bool ClearCallContext()

context.Clear();
CallContext.FreeNamedDataSlot(CallContextSlotName);
Trace.WriteLine(
string.Format(CultureInfo.InvariantCulture, "### Cleared async context: {0}", context.GetHashCode().ToString()));
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Aspects/Wcf/PerAsyncCallContextLifetimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void RemoveValue()
AsyncCallContext.FreeDataSlot(Key);
}

AsyncCallContext AsyncCallContext
static AsyncCallContext AsyncCallContext
{
get
{
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Wcf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[assembly: AssemblyTitle("Wcf")]
[assembly: AssemblyDescription("A set of classes and generics simplifying the initial configuration work of creating WCF services.")]

[assembly: AssemblyVersion("1.0.50")]
[assembly: AssemblyFileVersion("1.0.50")]
[assembly: AssemblyInformationalVersion("1.0.50")]
[assembly: AssemblyVersion("1.0.51")]
[assembly: AssemblyFileVersion("1.0.51")]
[assembly: AssemblyInformationalVersion("1.0.51")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Wcf.Test, " +
Expand Down

0 comments on commit 5056bbd

Please sign in to comment.