-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #686 from jbogard/contracts-assembly
Contracts assembly separated out into separate package
- Loading branch information
Showing
7 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Taken from psake https://github.com/psake/psake | ||
|
||
<# | ||
.SYNOPSIS | ||
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode | ||
to see if an error occcured. If an error is detected then an exception is thrown. | ||
This function allows you to run command-line programs without having to | ||
explicitly check the $lastexitcode variable. | ||
.EXAMPLE | ||
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed" | ||
#> | ||
function Exec | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd, | ||
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd) | ||
) | ||
& $cmd | ||
if ($lastexitcode -ne 0) { | ||
throw ("Exec: " + $errorMessage) | ||
} | ||
} | ||
|
||
$artifacts = ".\artifacts" | ||
$contracts = ".\src\MediatR.Contracts\MediatR.Contracts.csproj" | ||
|
||
if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse } | ||
|
||
exec { & dotnet clean $contracts -c Release } | ||
|
||
exec { & dotnet build $contracts -c Release -p:ContinuousIntegrationBuild=true } | ||
|
||
exec { & dotnet pack $contracts -c Release -o $artifacts --no-build } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MediatR; | ||
|
||
/// <summary> | ||
/// Marker interface to represent a notification | ||
/// </summary> | ||
public interface INotification { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace MediatR; | ||
|
||
/// <summary> | ||
/// Marker interface to represent a request with a void response | ||
/// </summary> | ||
public interface IRequest : IRequest<Unit> { } | ||
|
||
/// <summary> | ||
/// Marker interface to represent a request with a response | ||
/// </summary> | ||
/// <typeparam name="TResponse">Response type</typeparam> | ||
public interface IRequest<out TResponse> : IBaseRequest { } | ||
|
||
/// <summary> | ||
/// Allows for generic type constraints of objects implementing IRequest or IRequest{TResponse} | ||
/// </summary> | ||
public interface IBaseRequest { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace MediatR; | ||
|
||
/// <summary> | ||
/// Marker interface to represent a request with a streaming response | ||
/// </summary> | ||
/// <typeparam name="TResponse">Response type</typeparam> | ||
public interface IStreamRequest<out TResponse> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<Authors>Jimmy Bogard</Authors> | ||
<Description>Contracts package for requests, responses, and notifications</Description> | ||
<Copyright>Copyright Jimmy Bogard</Copyright> | ||
<TargetFrameworks>netstandard2.1</TargetFrameworks> | ||
<Nullable>enable</Nullable> | ||
<Features>strict</Features> | ||
<PackageTags>mediator;request;response;queries;commands;notifications</PackageTags> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\..\MediatR.snk</AssemblyOriginatorKeyFile> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageIcon>gradient_128x128.png</PackageIcon> | ||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<Deterministic>true</Deterministic> | ||
<Version>1.0.0</Version> | ||
<RootNamespace>MediatR</RootNamespace> | ||
|
||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\assets\logo\gradient_128x128.png" Pack="true" PackagePath="" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
namespace MediatR; | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
/// <summary> | ||
/// Represents a void type, since <see cref="System.Void"/> is not a valid return type in C#. | ||
/// </summary> | ||
public readonly struct Unit : IEquatable<Unit>, IComparable<Unit>, IComparable | ||
{ | ||
private static readonly Unit _value = new(); | ||
|
||
/// <summary> | ||
/// Default and only value of the <see cref="Unit"/> type. | ||
/// </summary> | ||
public static ref readonly Unit Value => ref _value; | ||
|
||
/// <summary> | ||
/// Task from a <see cref="Unit"/> type. | ||
/// </summary> | ||
public static Task<Unit> Task { get; } = System.Threading.Tasks.Task.FromResult(_value); | ||
|
||
/// <summary> | ||
/// Compares the current object with another object of the same type. | ||
/// </summary> | ||
/// <param name="other">An object to compare with this object.</param> | ||
/// <returns> | ||
/// A value that indicates the relative order of the objects being compared. | ||
/// The return value has the following meanings: | ||
/// - Less than zero: This object is less than the <paramref name="other" /> parameter. | ||
/// - Zero: This object is equal to <paramref name="other" />. | ||
/// - Greater than zero: This object is greater than <paramref name="other" />. | ||
/// </returns> | ||
public int CompareTo(Unit other) => 0; | ||
|
||
/// <summary> | ||
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. | ||
/// </summary> | ||
/// <param name="obj">An object to compare with this instance.</param> | ||
/// <returns> | ||
/// A value that indicates the relative order of the objects being compared. | ||
/// The return value has these meanings: | ||
/// - Less than zero: This instance precedes <paramref name="obj" /> in the sort order. | ||
/// - Zero: This instance occurs in the same position in the sort order as <paramref name="obj" />. | ||
/// - Greater than zero: This instance follows <paramref name="obj" /> in the sort order. | ||
/// </returns> | ||
int IComparable.CompareTo(object? obj) => 0; | ||
|
||
/// <summary> | ||
/// Returns a hash code for this instance. | ||
/// </summary> | ||
/// <returns> | ||
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. | ||
/// </returns> | ||
public override int GetHashCode() => 0; | ||
|
||
/// <summary> | ||
/// Determines whether the current object is equal to another object of the same type. | ||
/// </summary> | ||
/// <param name="other">An object to compare with this object.</param> | ||
/// <returns> | ||
/// <c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>. | ||
/// </returns> | ||
public bool Equals(Unit other) => true; | ||
|
||
/// <summary> | ||
/// Determines whether the specified <see cref="System.Object" /> is equal to this instance. | ||
/// </summary> | ||
/// <param name="obj">The object to compare with the current instance.</param> | ||
/// <returns> | ||
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>. | ||
/// </returns> | ||
public override bool Equals(object? obj) => obj is Unit; | ||
|
||
/// <summary> | ||
/// Determines whether the <paramref name="first"/> object is equal to the <paramref name="second"/> object. | ||
/// </summary> | ||
/// <param name="first">The first object.</param> | ||
/// <param name="second">The second object.</param> | ||
/// <c>true</c> if the <paramref name="first"/> object is equal to the <paramref name="second" /> object; otherwise, <c>false</c>. | ||
public static bool operator ==(Unit first, Unit second) => true; | ||
|
||
/// <summary> | ||
/// Determines whether the <paramref name="first"/> object is not equal to the <paramref name="second"/> object. | ||
/// </summary> | ||
/// <param name="first">The first object.</param> | ||
/// <param name="second">The second object.</param> | ||
/// <c>true</c> if the <paramref name="first"/> object is not equal to the <paramref name="second" /> object; otherwise, <c>false</c>. | ||
public static bool operator !=(Unit first, Unit second) => false; | ||
|
||
/// <summary> | ||
/// Returns a <see cref="System.String" /> that represents this instance. | ||
/// </summary> | ||
/// <returns>A <see cref="System.String" /> that represents this instance.</returns> | ||
public override string ToString() => "()"; | ||
} |