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
96 changes: 33 additions & 63 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: Deploy
on:
push:
branches: [ master ]
branches: [ master ]

jobs:
test:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- name: "Build and Test"
run: |
dotnet build
dotnet test
version:
needs: test
runs-on: windows-latest
outputs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.newversion.outputs.version }}
tag: ${{ steps.newversion.outputs.tag }}
tag: ${{ steps.newversion.outputs.tag }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set New Version
Expand All @@ -36,22 +36,17 @@ jobs:
run: |
$currentVersion = git describe --abbrev=0 --tags --match "v[0-9]*.[0-9]*.[0-9]*-Release"

if ($currentVersion) {
if ($currentVersion -ne $null) {
$v = $currentVersion.Split('-')[0].TrimStart('v')
Write-Output "RELEASE: New Version: $($v)"
Write-Output "version=$($v)" >> $Env:GITHUB_OUTPUT
Write-Output "tag=$($currentVersion)" >> $Env:GITHUB_OUTPUT
} else {

$currentVersion = git describe --abbrev=0 --tags --match "v[0-9]*.[0-9]*.[0-9]*"
$currentVersion = git describe --match "$($currentVersion)" --long
$versionParts = $currentVersion.Split('-')
$v = $versionParts[0]
$increment = [int]$versionParts[1]

if ($increment -gt 0) {
$increment = 1
}
$increment = 1

$vparts = $v.Split('.')
$vparts[2] = "$([int]$vparts[2] + [int]$increment)"
Expand All @@ -63,49 +58,48 @@ jobs:
}
prepublish:
needs: [test, version]
runs-on: windows-latest
runs-on: ubuntu-latest
outputs:
description: ${{ steps.meta.outputs.description }}
changeinfo: ${{ steps.meta.outputs.changeinfo }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
fetch-depth: 0
- name : Get Meta Data
shell: pwsh
id: meta
run: |
[xml]$xml = get-content "src/Autofac.EasyPropInject.csproj"
[xml]$xml = get-content "src/Autofac.EasyPropInject.csproj"
$description = $xml.SelectSingleNode("//Description").InnerText;
$changes = $xml.SelectSingleNode("//PackageReleaseNotes").InnerText;
Write-Output "description=$($description.Trim().Replace("`t", '') | ConvertTo-Json)" >> $Env:GITHUB_OUTPUT
Write-Output "changeinfo=$($changes.Trim().Replace("`t", '') | ConvertTo-Json)" >> $Env:GITHUB_OUTPUT

publish:
needs: [test, version, prepublish]
runs-on: windows-latest
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Create Package
run: |
dotnet build src/Autofac.EasyPropInject.csproj -c Release -p:AssemblyVersion=${{ needs.version.outputs.version }} -p:PackageVersion=${{ needs.version.outputs.version }}
dotnet pack src/Autofac.EasyPropInject.csproj -c Release -p:AssemblyVersion=${{ needs.version.outputs.version }} -p:PackageVersion=${{ needs.version.outputs.version }} --output nget_pkg
- name: Create Release and Tag
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version.outputs.version }}
release_name: Release v${{ needs.version.outputs.version }}
tag_name: v${{ needs.version.outputs.version }}
name: Release v${{ needs.version.outputs.version }}
body: |
# Release Info Version ${{ needs.version.outputs.version }}
## Info
Expand All @@ -114,36 +108,12 @@ jobs:
${{fromJSON(needs.prepublish.outputs.changeinfo)}}
draft: false
prerelease: false
files: |
./nget_pkg/Autofac.EasyPropInject.${{ needs.version.outputs.version }}.nupkg
src/bin/Release/net10.0/Autofac.EasyPropInject.dll
- name: Delete Release Tag
if: ${{needs.version.outputs.tag}}
uses: dev-drprasad/delete-tag-and-release@v1.0
with:
tag_name: ${{needs.version.outputs.tag}}
github_token: ${{ secrets.GITHUB_TOKEN }}
delete_release: false
- name: Upload Release Asset Pkg
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./nget_pkg/Autofac.EasyPropInject.${{ needs.version.outputs.version }}.nupkg
asset_name: Autofac.EasyPropInject.${{ needs.prepublish.version.version }}.nupkg
asset_content_type: application/zip
- name: Upload Release Asset DLL
id: upload-release-asset2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: src/bin/Release/netstandard2.1/Autofac.EasyPropInject.dll
asset_name: Autofac.EasyPropInject.dll
asset_content_type: application/octet-stream
if: ${{ needs.version.outputs.tag }}
run: git push --delete origin ${{ needs.version.outputs.tag }}
- name: Publish package to nuget
id: nugetpush
run: dotnet nuget push "nget_pkg/Autofac.EasyPropInject.${{ needs.version.outputs.version }}.nupkg" -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json



run: dotnet nuget push "nget_pkg/Autofac.EasyPropInject.${{ needs.version.outputs.version }}.nupkg" -k ${{secrets.NUGET_KEY}} -s https://api.nuget.org/v3/index.json
14 changes: 7 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ name: Pull Request Check
on:
pull_request:
branches:
- master
- master
jobs:
test:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET 68
uses: actions/setup-dotnet@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- name: "Build and Test"
run: |
dotnet build
dotnet test
dotnet test
2 changes: 1 addition & 1 deletion Autofac.EasyPropInject.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.EasyPropInject", "s
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6970F006-BA29-4CC6-9D54-F7F22322F61B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.EasyPropInject.Testing", "tests\Autofac.EasyPropInject.Testing\Autofac.EasyPropInject.Testing.csproj", "{3BEF2E53-4346-45B2-935B-2E7DCA48EF99}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.EasyPropInject.Testing", "tests\Autofac.EasyPropInject.Testing\Autofac.EasyPropInject.Testing.csproj", "{3BEF2E53-4346-45B2-935B-2E7DCA48EF99}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
73 changes: 73 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [3.0.0]
### Added
- `EasyPropInjectOptions`, configurable via `AddEasyPropInject(options => ...)`
- `UnresolvedPropertyBehavior` to choose what happens to a `[FromAutofac]` property whose service is not
registered: `Skip` (default, leave it untouched) or `SetNull` (the behaviour of 2.x and earlier)
- A `net10.0` build next to the existing `netstandard2.1` one

### Changed
- Upgraded to Autofac 9.x
- Resolving is roughly three times faster. Measured over 2,000,000 resolves on .NET 10: a component with
decorated properties went from ~3.2s to ~1.0s, a component without any from ~2.0s to ~0.7s. Two things
got it there:
- Property metadata (the decorated properties, the service to resolve for each of them and the setter) is
collected once per type and cached. Previously every single resolve called `GetProperties()` on the
concrete type and asked every property for its attributes
- Properties are written through emitted setters instead of `PropertyInfo.SetValue`, which also removes
the boxing of every assignment
- EasyPropInject is now added as a service middleware source instead of hooking the registry's `Registered`
event and every registration's `PipelineBuilding` event. One middleware instance is shared by the whole
container instead of allocating one per component registration, and `AddEasyPropInject()` may be called at
any point while configuring the builder — before, after or in between registrations. The README used to
claim it had to come first; that restriction is gone and is covered by tests
- Shared instances are explicitly skipped once they have been activated (`NewInstanceActivated`), rather
than relying on the resolve pipeline to short-circuit before the middleware is reached
- A decorated property without a setter now throws an `InvalidOperationException` naming the type and the
property instead of an opaque `ArgumentException` from deep inside reflection
- `FromAutofacAttribute` is `sealed` and its `ResolveFromRegisteredType` is annotated as nullable

### Fixed
- Private and protected properties declared on a **base** class were never injected. Reflection does not
return non-public members of base types, so the type hierarchy is now walked explicitly
- A property whose service could not be resolved was unconditionally overwritten with `null`, silently
wiping any value assigned in the constructor. The result of the resolve attempt is now respected — see
`UnresolvedPropertyBehavior` if you relied on the old behaviour

## [2.0.0]
### Changed
- Upgraded to Autofac 8.x

## [1.2.5]
### Added
- Support for private and protected properties

### Changed
- Upgraded to Autofac 6.3.x

## [1.2.4]
### Changed
- Upgraded to Autofac 6.2.x

## [1.2.3]
### Changed
- Upgraded to Autofac 6.1.x

## [1.2.0]
### Added
- `FromAutofacAttribute.ResolveFromRegisteredType` to load a property as a different type from the container

### Changed
- Reimplemented Easy Prop Inject for Autofac 6.x

## [1.1.1]
### Changed
- Support for Autofac 5.x

## [1.0.0]
### Added
- Initial release with tests
Loading