Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove .NET 4.6.1 support; netstandard2.0/.NET 4.7.2 new minimum #1161

Merged
merged 9 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ x64/
# Visual Studio 2015 cache/options directory
.dotnet/
.vs/
.vscode/
.cr/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
Expand Down
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"formulahendry.dotnet-test-explorer",
"ms-dotnettools.csharp",
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint"
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true
}
23 changes: 23 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"tasks": [
{
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"command": "dotnet",
"group": {
"isDefault": true,
"kind": "build"
},
"label": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile",
"type": "shell"
}
],
"version": "2.0.0"
}
15 changes: 12 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,26 @@ We use [semantic versioning](https://semver.org/) for our package versions.

### Developer Environment

- Visual Studio 2019
**Windows**:

- Visual Studio 2019 or VS Code
- .NET Core SDK (each repo has a `global.json` with the version required)
- PowerShell 5+ / PowerShell Core

**Mac**:

- VS Code
- .NET Core SDK (each repo has a `global.json` with the version required)
- PowerShell 5+
- PowerShell 5+ / PowerShell Core
- Mono - install the latest "Visual Studio channel" version; the standalone version or the one from Homebrew won't work.

### Build / Test

Project codelines with scripted builds generally have a `build.ps1` script. This Powershell script will build, package, and execute tests.

Some project codelines rely on convention-based builds so do not have a specific script. In these cases you will not see a `.ps1` or `.proj` file to execute. In these cases...

- The build is executed by running it in Visual Studio or by executing `msbuild Solution.sln` on the solution in the codeline root.
- The build is executed by running it in Visual Studio or by executing `dotnet build Autofac.sln` on the solution in the codeline root.
- Unit tests can be run from the Visual Studio test explorer or by manually executing the command-line unit test runner from the `packages` folder against the built unit test assembly.

Unit tests are written in XUnit and Moq. **Code contributions should include tests that exercise/demonstrate the contribution.**
Expand Down
12 changes: 4 additions & 8 deletions src/Autofac/Autofac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>Autofac is an IoC container for Microsoft .NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity.</Description>
<!-- VersionPrefix patched by AppVeyor -->
<VersionPrefix>0.0.1</VersionPrefix>
<TargetFrameworks>netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);CS1591;IDE0008</NoWarn>
Expand Down Expand Up @@ -35,8 +35,8 @@
<Product>Autofac</Product>
</PropertyGroup>

<!-- Disable nullability warnings in netstandard2.0 and net461 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
<!-- Disable nullability warnings in netstandard2.0 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<NoWarn>$(NoWarn);8600;8601;8602;8603;8604</NoWarn>
</PropertyGroup>

Expand All @@ -59,14 +59,10 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.ComponentModel.Composition" />
</ItemGroup>

<ItemGroup>
<Compile Update="Builder\BuildCallbackServiceResources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
52 changes: 38 additions & 14 deletions src/Autofac/Core/Diagnostics/DefaultDiagnosticTracer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Autofac.Core.Resolving;
Expand All @@ -24,6 +25,15 @@ public class DefaultDiagnosticTracer : IResolvePipelineTracer
/// </summary>
public event EventHandler<OperationTraceCompletedArgs>? OperationCompleted;

/// <summary>
/// Gets the number of operations in progress being traced.
/// </summary>
/// <value>
/// An <see cref="int"/> with the number of trace IDs associated
/// with in-progress operations being traced by this tracer.
/// </value>
public int OperationsInProgress => this._operationBuilders.Count;

/// <inheritdoc/>
void IResolvePipelineTracer.OperationStart(ResolveOperationBase operation, ResolveRequest initiatingRequest)
{
Expand Down Expand Up @@ -125,14 +135,21 @@ void IResolvePipelineTracer.OperationFailure(ResolveOperationBase operation, Exc
{
if (_operationBuilders.TryGetValue(operation.TracingId, out var builder))
{
builder.Outdent();
builder.AppendLine(TracerMessages.ExitBrace);
builder.AppendException(TracerMessages.OperationFailed, operationException);

// If we're completing the root operation, raise the event.
if (operation.IsTopLevelOperation)
try
{
OperationCompleted?.Invoke(this, new OperationTraceCompletedArgs(operation, builder.ToString()));
builder.Outdent();
builder.AppendLine(TracerMessages.ExitBrace);
builder.AppendException(TracerMessages.OperationFailed, operationException);

// If we're completing the root operation, raise the event.
if (operation.IsTopLevelOperation)
{
OperationCompleted?.Invoke(this, new OperationTraceCompletedArgs(operation, builder.ToString()));
}
}
finally
{
_operationBuilders.TryRemove(operation.TracingId, out var _);
}
}
}
Expand All @@ -142,14 +159,21 @@ void IResolvePipelineTracer.OperationSuccess(ResolveOperationBase operation, obj
{
if (_operationBuilders.TryGetValue(operation.TracingId, out var builder))
{
builder.Outdent();
builder.AppendLine(TracerMessages.ExitBrace);
builder.AppendFormattedLine(TracerMessages.OperationSucceeded, resolvedInstance);

// If we're completing the root operation, raise the event.
if (operation.IsTopLevelOperation)
try
{
builder.Outdent();
builder.AppendLine(TracerMessages.ExitBrace);
builder.AppendFormattedLine(TracerMessages.OperationSucceeded, resolvedInstance);

// If we're completing the root operation, raise the event.
if (operation.IsTopLevelOperation)
{
OperationCompleted?.Invoke(this, new OperationTraceCompletedArgs(operation, builder.ToString()));
}
}
finally
{
OperationCompleted?.Invoke(this, new OperationTraceCompletedArgs(operation, builder.ToString()));
_operationBuilders.TryRemove(operation.TracingId, out var _);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Autofac/Util/NullableAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma warning disable MA0048 // File name must match type name
#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name
#if NETSTANDARD2_0 || NET461
#if NETSTANDARD2_0

namespace System.Diagnostics.CodeAnalysis
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591;SA1602;SA1611</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
Expand All @@ -14,16 +14,12 @@
<ProjectReference Include="..\Autofac.Test.Scenarios.ScannedAssembly\Autofac.Test.Scenarios.ScannedAssembly.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.ComponentModel.Composition" />
</ItemGroup>

<ItemGroup>
<Compile Remove="TestResults\**" />
<EmbeddedResource Remove="TestResults\**" />
<None Remove="TestResults\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ public void DiagnosticTracerDoesNotRaiseAnEventOnNestedOperations()
Assert.Contains("Decorator", lastOpResult);
}

[Fact]
public void DiagnosticTracerDoesNotLeakMemory()
{
var tracer = new DefaultDiagnosticTracer();

var containerBuilder = new ContainerBuilder();
containerBuilder.RegisterType<Implementor>().As<IService>();
containerBuilder.RegisterDecorator<Decorator, IService>();

var container = containerBuilder.Build();

container.AttachTrace(tracer);
container.Resolve<IService>();

// The dictionary of tracked trace IDs and
// string builders should be empty.
Assert.Equal(0, tracer.OperationsInProgress);
}

private interface IService
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Autofac.Test.Scenarios.ScannedAssembly</AssemblyName>
Expand Down
10 changes: 1 addition & 9 deletions test/Autofac.Test/Autofac.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591;SA1602;SA1611</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -36,14 +36,6 @@
</PackageReference>
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
<DefineConstants>$(DefineConstants);PARTIAL_TRUST</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.ComponentModel.Composition" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
100 changes: 0 additions & 100 deletions test/Autofac.Test/PartialTrust/PartialTrustTestExecutor.cs

This file was deleted.

Loading