Skip to content
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
364 changes: 228 additions & 136 deletions .editorconfig

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
rev: "3e8a8703264a2f4a69428a0aa4dcb512790b2c8c" # frozen: v6.0.0
hooks:
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: e72a3ca1632f0b11a07d171449fe447a7ff6795e # frozen: v0.48.0
rev: "e72a3ca1632f0b11a07d171449fe447a7ff6795e" # frozen: v0.48.0
hooks:
- id: markdownlint
args:
- --fix
- repo: https://github.com/tillig/json-sort-cli
rev: 2b7e147e0933bd30b58133b6f287e5c695ff4f0e # frozen: v3.0.1
rev: "2b7e147e0933bd30b58133b6f287e5c695ff4f0e" # frozen: v3.0.1
hooks:
- id: json-sort
args:
Expand Down
58 changes: 24 additions & 34 deletions build/Source.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,39 @@
<Rules AnalyzerId="Microsoft.Usage" RuleNamespace="Microsoft.Usage">
<!-- Implement standard exception constructors - not all of the exception constructors (e.g., parameterless) are desired in our system. -->
<Rule Id="CA1032" Action="None" />
<!-- Avoid excessive inheritance (must be explicitly enabled). -->
<Rule Id="CA1501" Action="Warning" />
<!-- Avoid excessive complexity (must be explicitly enabled). -->
<Rule Id="CA1502" Action="Warning" />
<!-- Avoid unmaintainable code (must be explicitly enabled). -->
<Rule Id="CA1505" Action="Warning" />
<!-- Avoid excessive class coupling (must be explicitly enabled). -->
<Rule Id="CA1506" Action="Warning" />
<!-- Use ArgumentNullException.ThrowIfNull - this isn't available until we stop targeting netstandard. -->
<Rule Id="CA1510" Action="None" />
<!-- Use ArgumentOutOfRangeException.ThrowIfNegative - this isn't available until we stop targeting anything below net8.0. -->
<Rule Id="CA1512" Action="None" />
<!-- Use ObjectDisposedException.ThrowIf - this isn't available until we stop targeting anything below net8.0. -->
<Rule Id="CA1513" Action="None" />
<!-- Change names to avoid reserved word overlaps (e.g., Delegate, GetType, etc.) - too many of these in the public API, we'd break if we fixed it. -->
<Rule Id="CA1716" Action="None" />
<!-- Implement serialization constructors - false positive when building .NET Core -->
<!-- Cache a CompositeFormat object for use in String.Format - this isn't available until we stop targeting netstandard, and we only String.Format when throwing exceptions so the work/complexity isn't justified to increase perf just for those situations. -->
<Rule Id="CA1863" Action="None" />
<!-- Implement serialization constructors - false positive when building .NET Core. -->
<Rule Id="CA2229" Action="None" />
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core -->
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core. -->
<Rule Id="CA2237" Action="None" />
<!-- Prefer generic overloads to using Type parameters - many aren't available in earlier frameworks; and we do a lot of reflection work in Autofac. -->
<Rule Id="CA2263" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!-- Prefix local calls with this -->
<!-- Prefix local calls with this. -->
<Rule Id="SA1101" Action="None" />
<!-- Use built-in type alias -->
<!-- Use built-in type alias. -->
<Rule Id="SA1121" Action="None" />
<!-- Use String.Empty instead of "" -->
<!-- Use String.Empty instead of "". -->
<Rule Id="SA1122" Action="None" />
<!-- Using statements must be inside a namespace -->
<Rule Id="SA1200" Action="None" />
<!-- Enforce order of class members by member type -->
<Rule Id="SA1201" Action="None" />
<!-- Enforce order of class members by member visibility -->
<Rule Id="SA1202" Action="None" />
<!-- Enforce order of constantand static members -->
<Rule Id="SA1203" Action="None" />
<!-- Enforce order of static vs. non-static members -->
<Rule Id="SA1204" Action="None" />
<!-- Modifiers are not ordered - .editorconfig handles this -->
<Rule Id="SA1206" Action="None" />
<!-- Enforce order of readonly vs. non-readonly members -->
<Rule Id="SA1214" Action="None" />
<!-- Fields can't start with underscore -->
<!-- Fields can't start with underscore. -->
<Rule Id="SA1309" Action="None" />
<!-- Suppressions must have a justification -->
<Rule Id="SA1404" Action="None" />
<!-- Parameter documentation must be in the right order -->
<Rule Id="SA1612" Action="None" />
<!-- Return value must be documented -->
<Rule Id="SA1615" Action="None" />
<!-- Generic type parameters must be documented -->
<Rule Id="SA1618" Action="None" />
<!-- Don't copy/paste documentation -->
<Rule Id="SA1625" Action="None" />
<!-- Exception documentation must not be empty -->
<Rule Id="SA1627" Action="None" />
<!-- Enable XML documentation output-->
<Rule Id="SA1652" Action="None" />
</Rules>
</RuleSet>
87 changes: 54 additions & 33 deletions build/Test.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,86 @@
<RuleSet Name="Autofac Analyzer Rules" Description="Analyzer rules for Autofac assemblies." ToolsVersion="16.0">
<IncludeAll Action="Warning" />
<Rules AnalyzerId="Microsoft.Usage" RuleNamespace="Microsoft.Usage">
<!-- Avoid excessive parameters on generic types (must be explicitly enabled). -->
<Rule Id="CA1005" Action="Warning" />
<!-- Don't catch general exceptions - test scenarios sometimes require general exception handling. -->
<Rule Id="CA1031" Action="None" />
<!-- Implement standard exception constructors - not all of the exception constructors (e.g., parameterless) are desired in our system. -->
<Rule Id="CA1032" Action="None" />
<!-- Do not nest types - we do that special for the DynamicProxy testing because there are lots of overlapping scenarios to test and interfaces/classes do need to be public. -->
<Rule Id="CA1034" Action="None" />
<!-- Identifiers should not contain underscores - underscores are helpful in test naming. -->
<!-- Avoid empty interfaces - in unit tests for service resolution, this happens a lot. -->
<Rule Id="CA1040" Action="None" />
<!-- Do not pass literals as localized parameters - tests don't need to localize. -->
<Rule Id="CA1303" Action="None" />
<!-- Avoid excessive inheritance (must be explicitly enabled). -->
<Rule Id="CA1501" Action="Warning" />
<!-- Avoid excessive complexity (must be explicitly enabled). -->
<Rule Id="CA1502" Action="Warning" />
<!-- Avoid unmaintainable code (must be explicitly enabled). -->
<Rule Id="CA1505" Action="Warning" />
<!-- Avoid excessive class coupling (must be explicitly enabled). -->
<Rule Id="CA1506" Action="Warning" />
<!-- Use ArgumentNullException.ThrowIfNull - this isn't available until we stop targeting netstandard. -->
<Rule Id="CA1510" Action="None" />
<!-- Make API types internal - causes problems with tests and test assemblies. -->
<Rule Id="CA1515" Action="None" />
<!-- Remove the underscores from member name - unit test scenarios may use underscores. -->
<Rule Id="CA1707" Action="None" />
<!-- Change names to avoid reserved word overlaps (e.g., Delegate, GetType, etc.) - too many of these in the public API, we'd break if we fixed it. -->
<Rule Id="CA1716" Action="None" />
<!-- Internal class that appears to never be instantiated - lots of false positives here because they're test stubs created by Autofac registrations. -->
<Rule Id="CA1812" Action="None" />
<!-- Change Dispose() to call GC.SuppressFinalize - in tests we don't really care and it can impact readability. -->
<Rule Id="CA1816" Action="None" />
<!-- Mark members static - test methods may not access member data but also can't be static. -->
<Rule Id="CA1822" Action="None" />
<!-- Implement serialization constructors - false positive when building .NET Core -->
<!-- Seal internal types for performance - in tests we don't really care and it gets painful to enforce. -->
<Rule Id="CA1852" Action="None" />
<!-- Prefer static readonly fields over constant array arguments - constant array arguments happen a lot in unit tests for assertions and test setup. -->
<Rule Id="CA1861" Action="None" />
<!-- Cache a CompositeFormat object for use in String.Format - this makes unit tests harder to read, and performance isn't an issue. -->
<Rule Id="CA1863" Action="None" />
<!-- Call ConfigureAwait on tasks - you shouldn't do this in unit test libraries; XUnit has an opposite analyzer. -->
<Rule Id="CA2007" Action="None" />
<!-- Implement serialization constructors - false positive when building .NET Core. -->
<Rule Id="CA2229" Action="None" />
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core -->
<!-- Use Uri instead of string parameters - strings are easier for testing. -->
<Rule Id="CA2234" Action="None" />
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core. -->
<Rule Id="CA2237" Action="None" />
<!-- Prefer generic overloads to using Type parameters - we do a lot of reflection work in Autofac that needs to be tested. -->
<Rule Id="CA2263" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!-- Prefix local calls with this -->
<!-- Prefix local calls with this. -->
<Rule Id="SA1101" Action="None" />
<!-- Use built-in type alias -->
<!-- Use built-in type alias. -->
<Rule Id="SA1121" Action="None" />
<!-- Use String.Empty instead of "" -->
<!-- Use String.Empty instead of "". -->
<Rule Id="SA1122" Action="None" />
<!-- Using statements must be inside a namespace -->
<Rule Id="SA1200" Action="None" />
<!-- Enforce order of class members by member type -->
<!-- Enforce order of class members by member type - sometimes putting test classes/data by the test helps. -->
<Rule Id="SA1201" Action="None" />
<!-- Enforce order of class members by member visibility -->
<!-- Enforce order of class members by member visibility - sometimes putting test classes/data by the test helps. -->
<Rule Id="SA1202" Action="None" />
<!-- Enforce order of constantand static members -->
<Rule Id="SA1203" Action="None" />
<!-- Enforce order of static vs. non-static members -->
<!-- Enforce order of static vs. non-static members - sometimes putting test classes/data by the test helps. -->
<Rule Id="SA1204" Action="None" />
<!-- Modifiers are not ordered - .editorconfig handles this -->
<Rule Id="SA1206" Action="None" />
<!-- Enforce order of readonly vs. non-readonly members -->
<Rule Id="SA1214" Action="None" />
<!-- Fields can't start with underscore -->
<!-- Fields can't start with underscore. -->
<Rule Id="SA1309" Action="None" />
<!-- Suppressions must have a justification -->
<Rule Id="SA1404" Action="None" />
<!-- Elements should be documented -->
<!-- Elements should be documented. -->
<Rule Id="SA1600" Action="None" />
<!-- Enuemration items should be documented -->
<!-- Partial items should be documented. -->
<Rule Id="SA1601" Action="None" />
<!-- Enumeration items should be documented. -->
<Rule Id="SA1602" Action="None" />
<!-- Parameter documentation must be in the right order -->
<!-- Parameter should be documented. -->
<Rule Id="SA1611" Action="None" />
<!-- Parameter documentation must be in the right order. -->
<Rule Id="SA1612" Action="None" />
<!-- Return value must be documented -->
<!-- Return value must be documented. -->
<Rule Id="SA1615" Action="None" />
<!-- Generic type parameters must be documented -->
<!-- Generic type parameters must be documented. -->
<Rule Id="SA1618" Action="None" />
<!-- Don't copy/paste documentation -->
<!-- Don't copy/paste documentation. -->
<Rule Id="SA1625" Action="None" />
<Rule Id="SA1633" Action="None" />
<!-- Exception documentation must not be empty -->
<Rule Id="SA1627" Action="None" />
<!-- Enable XML documentation output-->
<Rule Id="SA1652" Action="None" />
<!-- Private member is unused - tests for reflection require members that may not get used. -->
<Rule Id="IDE0051" Action="None" />
<!-- Private member assigned value never read - tests for reflection require values that may not get used. -->
Expand Down
3 changes: 3 additions & 0 deletions build/stylecop.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"licenseName": "MIT"
},
"xmlHeader": false
},
"orderingRules": {
"usingDirectivesPlacement": "outsideNamespace"
}
}
}
88 changes: 57 additions & 31 deletions default.proj
Original file line number Diff line number Diff line change
@@ -1,41 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="Current">
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<PackageVersion Condition="'$(PackageVersion)' == ''">7.1.0</PackageVersion>
<Solution>$(MSBuildThisFileDirectory)Autofac.Extras.DynamicProxy.sln</Solution>
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
<PackagesPath>$(ArtifactsPath)/packages</PackagesPath>
<LogsPath>$(ArtifactsPath)/logs</LogsPath>
<!-- Increment the overall semantic version here. -->
<Version>7.1.0</Version>
<SolutionName>Autofac.Extras.DynamicProxy</SolutionName>
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<ArtifactDirectory>$([System.IO.Path]::Combine($(MSBuildProjectDirectory),"artifacts"))</ArtifactDirectory>
<PackageDirectory>$([System.IO.Path]::Combine($(ArtifactDirectory),"packages"))</PackageDirectory>
<LogDirectory>$([System.IO.Path]::Combine($(ArtifactDirectory),"logs"))</LogDirectory>
<CoverageRunSettings>$([System.IO.Path]::Combine($(MSBuildProjectDirectory),'build/Coverage.runsettings'))</CoverageRunSettings>
<BuildDateTime>$([System.DateTimeOffset]::UtcNow.ToString('yyyyMMddTHHmmssZ'))</BuildDateTime>
</PropertyGroup>

<!-- Clean -->
<Choose>
<When Condition="'$(GITHUB_REF_NAME)'==''">
<PropertyGroup>
<Version>$(Version)-local</Version>
</PropertyGroup>
</When>
<When Condition="'$(GITHUB_REF_NAME)'=='master' Or $([System.Text.RegularExpressions.Regex]::IsMatch($(GITHUB_REF_NAME), `^v.+\..+\..+`))">
<PropertyGroup>
<Version>$(Version)</Version>
</PropertyGroup>
</When>
<When Condition="'$(GITHUB_REF_NAME)'=='develop'">
<PropertyGroup>
<Version>$(Version)-beta$(BuildDateTime)</Version>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Version>$(Version)-alpha$(BuildDateTime)</Version>
</PropertyGroup>
</Otherwise>
</Choose>
<ItemGroup>
<FilesToDelete Include="$(ArtifactsPath)/**/*.*" />
<CleanDirectory Include="$(ArtifactDirectory)" />
<SourceProject Include="$(MSBuildProjectDirectory)/src/**/*.csproj" />
<TestProject Include="$(MSBuildProjectDirectory)/test/**/*.csproj" />
<SolutionFile Include="$(SolutionName).sln" />
</ItemGroup>

<Target Name="All">
<Message Text="****************************************" Importance="high" />
<Message Text="$(SolutionName) v$(Version)" Importance="high" />
<Message Text="$(Configuration) Configuration" Importance="high" />
<Message Text="$(BuildDateTime)" Importance="high" />
<Message Text="****************************************" Importance="high" />
<CallTarget Targets="Clean;Compile;Test;Package" />
</Target>
<Target Name="Clean">
<Delete Files="@(FilesToDelete)" />
<RemoveDir Directories="$(ArtifactsPath)" />
<RemoveDir Directories="@(CleanDirectory)" />
<RemoveDir Directories="%(SourceProject.RootDir)%(SourceProject.Directory)bin;%(SourceProject.RootDir)%(SourceProject.Directory)obj" />
<RemoveDir Directories="%(TestProject.RootDir)%(TestProject.Directory)bin;%(TestProject.RootDir)%(TestProject.Directory)obj" />
</Target>
<Target Name="Compile">
<Exec Command="dotnet --info" />
<Exec Command="dotnet build &quot;%(SolutionFile.FullPath)&quot; -c $(Configuration) /p:Version=$(Version)" />
</Target>

<!-- Build and pack -->
<Target Name="BuildPack" DependsOnTargets="Clean">
<Exec Command="dotnet build &quot;$(Solution)&quot; -c $(Configuration) -p:Version=$(PackageVersion) -warnaserror" />
<Exec Command="dotnet pack &quot;$(Solution)&quot; -c $(Configuration) -p:Version=$(PackageVersion) -o &quot;$(PackagesPath)&quot; --no-build -warnaserror" />
<Target Name="Package">
<MakeDir Directories="$(PackageDirectory)" />
<Exec Command="dotnet pack &quot;%(SourceProject.Identity)&quot; -c $(Configuration) --no-build --output &quot;$(PackageDirectory)&quot; /p:Version=$(Version)" />
</Target>

<!-- Test -->
<Target Name="Test" DependsOnTargets="BuildPack">
<ItemGroup>
<TestProjects Include="$(MSBuildThisFileDirectory)test/**/*Test.csproj" />
</ItemGroup>
<PropertyGroup>
<TestCounter>0</TestCounter>
</PropertyGroup>
<Exec Command="dotnet test &quot;%(TestProjects.FullPath)&quot; -c $(Configuration) --no-build --collect &quot;XPlat Code Coverage&quot; --settings:&quot;$(MSBuildThisFileDirectory)build/Coverage.runsettings&quot; --results-directory &quot;$(LogsPath)/%(TestProjects.Filename)&quot; -l:trx" />
<Target Name="Test">
<MakeDir Directories="$(LogDirectory)" />
<Exec Command="dotnet test &quot;%(TestProject.Identity)&quot; -c $(Configuration) --results-directory &quot;$(LogDirectory)&quot; --logger:trx /p:Version=$(Version) --collect:&quot;XPlat Code Coverage&quot; --settings &quot;$(CoverageRunSettings)&quot;" />
</Target>

<!-- Main build target -->
<Target Name="Build" DependsOnTargets="Test" />
</Project>
17 changes: 10 additions & 7 deletions src/Autofac.Extras.DynamicProxy/InterceptAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ namespace Autofac.Extras.DynamicProxy;
/// Indicates that a type should be intercepted.
/// </summary>
[ExcludeFromCodeCoverage]
[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Attribute is unsealed to allow derived types to provide additional interception metadata.")]
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "Constructor arguments are transformed into Service instances and exposed through InterceptorService property.")]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class InterceptAttribute : Attribute
{
/// <summary>
/// Gets the interceptor service.
/// </summary>
public Service InterceptorService { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="InterceptAttribute"/> class.
/// </summary>
Expand Down Expand Up @@ -49,4 +44,12 @@ public InterceptAttribute(Type interceptorServiceType)
: this(new TypedService(interceptorServiceType))
{
}

/// <summary>
/// Gets the interceptor service.
/// </summary>
public Service InterceptorService
{
get; private set;
}
}
Loading
Loading