Skip to content

Commit

Permalink
Merge pull request #23 from harrison314/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
harrison314 authored Nov 24, 2020
2 parents 9ff573f + 56230c4 commit 7756061
Show file tree
Hide file tree
Showing 32 changed files with 268 additions and 187 deletions.
90 changes: 64 additions & 26 deletions BuildScripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Specifies the amount of information to be displayed.
Shows description about tasks.
.PARAMETER DryRun
Performs a dry run.
.PARAMETER Experimental
Uses the nightly builds of the Roslyn script engine.
.PARAMETER Mono
Uses the Mono Compiler rather than the Roslyn script engine.
.PARAMETER SkipToolPackageRestore
Skips restoring of packages.
.PARAMETER ScriptArgs
Expand All @@ -41,21 +37,41 @@ https://cakebuild.net

[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Script,
[string]$Target,
[string]$Configuration,
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity,
[switch]$ShowDescription,
[Alias("WhatIf", "Noop")]
[switch]$DryRun,
[switch]$Experimental,
[switch]$Mono,
[switch]$SkipToolPackageRestore,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)

# This is an automatic variable in PowerShell Core, but not in Windows PowerShell 5.x
if (-not (Test-Path variable:global:IsCoreCLR)) {
$IsCoreCLR = $false
}

# Attempt to set highest encryption available for SecurityProtocol.
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
# will typically produce a message for PowerShell v2 (just an info
# message though)
try {
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
# installed (.NET 4.5 is an in-place upgrade).
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
if (-not $IsCoreCLR) {
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
}
} catch {
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
}

[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
function MD5HashFile([string] $filePath)
{
Expand Down Expand Up @@ -85,7 +101,7 @@ function GetProxyEnabledWebClient
{
$wc = New-Object System.Net.WebClient
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc.Proxy = $proxy
return $wc
}
Expand All @@ -96,6 +112,9 @@ if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}

if(!$Script){
$Script = Join-Path $PSScriptRoot "build.cake"
}
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
Expand All @@ -107,10 +126,14 @@ $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"

$env:CAKE_PATHS_TOOLS = $TOOLS_DIR
$env:CAKE_PATHS_ADDINS = $ADDINS_DIR
$env:CAKE_PATHS_MODULES = $MODULES_DIR

# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
Write-Verbose -Message "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
}

# Make sure that packages.config exist.
Expand Down Expand Up @@ -146,25 +169,37 @@ if (!(Test-Path $NUGET_EXE)) {
}
}

# These are automatic variables in PowerShell Core, but not in Windows PowerShell 5.x
if (-not (Test-Path variable:global:ismacos)) {
$IsLinux = $false
$IsMacOS = $false
}

# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$NUGET_EXE`""
} else {
"`"$NUGET_EXE`""
}

# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent) {
Push-Location
Set-Location $TOOLS_DIR

# Check for changes in packages.config and remove installed tools if true.
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
Remove-Item -Recurse
Remove-Item -Recurse -Force
}

Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet tools."
Expand All @@ -173,7 +208,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
{
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
}
Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
Expand All @@ -184,13 +219,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
Set-Location $ADDINS_DIR

Write-Verbose -Message "Restoring addins from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet addins."
}

Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
Expand All @@ -201,13 +236,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
Set-Location $MODULES_DIR

Write-Verbose -Message "Restoring modules from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet modules."
}

Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
Expand All @@ -217,20 +252,23 @@ if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe at $CAKE_EXE"
}

$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$CAKE_EXE`""
} else {
"`"$CAKE_EXE`""
}


# Build Cake arguments
$cakeArguments = @("$Script");
if ($Target) { $cakeArguments += "-target=$Target" }
# Build an array (not a string) of Cake arguments to be joined later
$cakeArguments = @()
if ($Script) { $cakeArguments += "`"$Script`"" }
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
if ($ShowDescription) { $cakeArguments += "-showdescription" }
if ($DryRun) { $cakeArguments += "-dryrun" }
if ($Experimental) { $cakeArguments += "-experimental" }
if ($Mono) { $cakeArguments += "-mono" }
$cakeArguments += $ScriptArgs

# Start Cake
Write-Host "Running build script..."
&$CAKE_EXE $cakeArguments
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
exit $LASTEXITCODE
17 changes: 16 additions & 1 deletion BuildScripts/build.cake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#addin nuget:?package=Cake.Git&version=0.21.0

var target = Argument("target", "Default");
var configuration = Argument("Configuration", "Release");
Expand All @@ -8,6 +9,19 @@ var configuration = Argument("Configuration", "Release");
string artefacts = "./Artifacts";

// ****************************************************************************

void UpdateSettings(DotNetCoreSettings settings)
{
if (settings.EnvironmentVariables == null)
{
settings.EnvironmentVariables = new Dictionary<string, string>();
}

var branch = GitBranchCurrent("..");
//settings.EnvironmentVariables.Add("RepositoryBranch", branch.FriendlyName);
settings.EnvironmentVariables.Add("RepositoryCommit", branch.Tip.Sha);
}

var netCoreBuildSettings = new DotNetCoreBuildSettings()
{
Configuration = configuration,
Expand All @@ -16,7 +30,7 @@ var netCoreBuildSettings = new DotNetCoreBuildSettings()
NoRestore = false
};

var netCoreDotNetCorePackSettings = new DotNetCorePackSettings ()
var netCoreDotNetCorePackSettings = new DotNetCorePackSettings()
{
Configuration = configuration,
OutputDirectory = artefacts,
Expand Down Expand Up @@ -150,6 +164,7 @@ Task("Pack")
.IsDependentOn("Test")
.Does(()=>
{
UpdateSettings(netCoreDotNetCorePackSettings);
foreach(var projFile in GetFiles("../src/Src/*/*.csproj"))
{
DotNetCorePack(projFile.ToString(), netCoreDotNetCorePackSettings);
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ Fertures:
* Proxy instance generator, for control instancing real implementation (e.g. lazy loading).

The following platforms are supported:
* .Net 4.0, 4.5, 4.6, 4.6.1, NetStandard 1.6, NetStandard 2.0 and UWP applications (NetStandard 1.4)
* .Net Framework 4.0, 4.5, 4.6, 4.6.1, NetStandard 1.6, NetStandard 2.0 and UWP applications (NetStandard 1.4), .Net 5.0

## Getting started

In package manager console:

`PM> Install-Package MassiveDynamicProxyGenerator`

Or
`dotnet add package MassiveDynamicProxyGenerator`

## A Quick Example

Examples of use MassiveDynamicProxyGenerator.
Expand Down Expand Up @@ -141,6 +144,10 @@ In package manager console:

`PM> Install-Package MassiveDynamicProxyGenerator.SimpleInjector`

Or

`dotnet add package MassiveDynamicProxyGenerator.SimpleInjector`

Or download [MassiveDynamicProxyGenerator.SimpleInjector](https://www.nuget.org/packages/MassiveDynamicProxyGenerator.SimpleInjector/).

### Register mock
Expand Down Expand Up @@ -267,6 +274,10 @@ In package manager console:

`PM> Install-Package MassiveDynamicProxyGenerator.Microsoft.DependencyInjection`

Or

`dotnet add package MassiveDynamicProxyGenerator.Microsoft.DependencyInjection`

Or download [MassiveDynamicProxyGenerator.Microsoft.DependencyInjection](https://www.nuget.org/packages/MassiveDynamicProxyGenerator.Microsoft.DependencyInjection/).

### Add decorators
Expand Down
5 changes: 2 additions & 3 deletions src/Samples/PerformaceExamples/PerformaceExamples.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 1 addition & 6 deletions src/Samples/SampleWebApplication/SampleWebApplication.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Src\MassiveDynamicProxyGenerator.Microsoft.DependencyInjection\MassiveDynamicProxyGenerator.Microsoft.DependencyInjection.csproj" />
<ProjectReference Include="..\..\Src\MassiveDynamicProxyGenerator\MassiveDynamicProxyGenerator.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SampleWebApplication.Services.Contract
{
public interface ICommonServices
{
IHostingEnvironment HostingEnvironment
IWebHostEnvironment HostingEnvironment
{
get;
}
Expand Down
17 changes: 11 additions & 6 deletions src/Samples/SampleWebApplication/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SampleWebApplication.Services.Contract;
using SampleWebApplication.Services.Implementation;
using SampleWebApplication.Services.Interceptors;
using Microsoft.Extensions.Hosting;

namespace SampleWebApplication
{
Expand All @@ -36,12 +37,12 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
services.AddProxy<INotificationService>();
services.AddProxy<ICommonServices, ServiceProviderInterceptor>();

services.AddMvc();
services.AddControllers();

return services.BuildIntercepedServiceProvider();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -54,11 +55,15 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseStaticFiles();

app.UseMvc(routes =>
app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllers();
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>WcfForHipsters.Client</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>WcfForHipsters.Client</PackageId>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 7756061

Please sign in to comment.