Skip to content
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/build-test-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and test on linux

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# Building requires an up-to-date .NET SDK.
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x

# Restore and build
- name: Restore dependencies
run: dotnet restore
- name: Build Nuget Versions
run: dotnet build ./tools/Explicit.NuGet.Versions/Explicit.NuGet.Versions.sln
- name: Build Release
run: dotnet build Castle.Windsor.sln -c Release

# Run tests for linux
- name: Test on .NET 6.0
run: |
dotnet test src/Castle.Windsor.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed"
dotnet test src/Castle.Facilities.AspNetCore.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed"
dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed"
34 changes: 34 additions & 0 deletions .github/workflows/build-test-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and test on Windows

on:
workflow_call:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

# Building requires an up-to-date .NET SDK.
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x

# Restore and build
- name: Restore dependencies
run: dotnet restore
- name: Build Release
run: dotnet build Castle.Windsor.sln -c Release

# Run tests on windows
- name: Test on .NET Framework 4.6.2 (Windows only)
run: |
dotnet test src/Castle.Windsor.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed"
dotnet test src/Castle.Facilities.AspNet.Mvc.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed"
dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed"
dotnet test src/Castle.Facilities.AspNet.WebApi.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed"
dotnet test src/Castle.Facilities.WcfIntegration.Tests -c Release -f net462 --no-build --no-restore -l "console;verbosity=detailed"
43 changes: 43 additions & 0 deletions .github/workflows/dotnet-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: .NET Release

on:
push:
tags:
- 'v*.*.*'

jobs:
build-lin:
name: Build and test Linux
uses: ./.github/workflows/build-test-linux.yml

build-win:
name: Build and test on Windows
uses: ./.github/workflows/build-test-win.yml

deploy:
needs: [build-lin, build-win]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Building requires an up-to-date .NET SDK.
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x

- name: Restore dependencies
run: dotnet restore
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d "v" -f 2)

- name: Build
run: dotnet build Castle.Windsor.sln -c Release
- name: Pack
run: dotnet pack Castle.Windsor.sln -c Release -o artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }}

- name: Push generated NuGet packages to GitHub Packages
run: dotnet nuget push "artifacts/*.nupkg" -k ${{secrets.GITHUB_TOKEN}} -s https://nuget.pkg.github.com/castleproject/index.json --skip-duplicate --no-symbols
16 changes: 16 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: .NET CI

on:
pull_request:
branches: [ master, main ]
paths-ignore:
- '**.md'

jobs:
build-lin:
name: Build and test Linux
uses: ./.github/workflows/build-test-linux.yml

build-win:
name: Build and test on Windows
uses: ./.github/workflows/build-test-win.yml
28 changes: 21 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
# Castle Windsor Changelog

## Unreleased
## 6.0.0 (2023-07-20)

- Add fast lookup to check for already registered types. (@sqeezy, #618)
- Change target framework from .NET Standard 1.6 to 2.0 (@generik0, #572)
- Castle.Windsor.Extensions.DependencyInjection: Change Microsoft.Extensions.Logging dependencies to their abstract counterparts (@ikkentim, #626, #624)
- Add `net6.0` as a target (@Jevonius, #621)
Target Framework changes:
- Added `net6.0` (@Jevonius, #621)
- .NET Standard changed from 1.6 to 2.0 (@generik0, #572)
- .NET Framework changed from 4.5 to 4.6.2

Enhancements:
- Added fast lookup to check for already registered types (@sqeezy, #618)
- `Castle.Windsor.Extensions.DependencyInjection`: Change `Microsoft.Extensions.Logging` dependencies to their abstract counterparts (@ikkentim, #626, #624)

Bugfixes:
- Castle.Windsor.Extensions.DependencyInjection: support parallel containers (@rvdginste, @generik0, #563, #577)
- `Castle.Windsor.Extensions.DependencyInjection`: support parallel containers (@rvdginste, @generik0, #563, #577)

Breaking Changes:
- Microsoft.Extensions.Hosting related methods have been removed from the Castle.Windsor.Extensions.DependencyInjection package to the Castle.Windsor.Extensions.Hosting package (@ikkentim, #625, #628)
- Microsoft.Extensions.Hosting related methods have been moved from the `Castle.Windsor.Extensions.DependencyInjection` package to the `Castle.Windsor.Extensions.Hosting` package (@ikkentim, #625, #628)
- Obsolete APIs in `Castle.Facilities.Logging` have been removed. Extensions methods for built-in logging factories have been added, however `LogUsing<T>` is still ideal. (@Jevonius, #636)
- Removed enum `Castle.Facilities.Logging.LoggerImplementation`
- Removed constructor `Castle.Facilities.Logging.LoggingFacility(LoggerImplementation loggingApi)`
- Removed constructor `Castle.Facilities.Logging.LoggingFacility(LoggerImplementation loggingApi, string configFile)`
- Removed constructor `Castle.Facilities.Logging.LoggingFacility(string customLoggerFactory, string configFile)`
- Removed method `Castle.Facilities.Logging.LoggingFacility.LogUsing(LoggerImplementation loggingApi)`
- Removed method `Castle.Facilities.Logging.LoggingFacility.UseLog4Net()`
- Removed method `Castle.Facilities.Logging.LoggingFacility.UseLog4Net(string configFile)`
- Removed method `Castle.Facilities.Logging.LoggingFacility.UseNLog()`
- Removed method `Castle.Facilities.Logging.LoggingFacility.UseNLog(string configFile)`

## 5.1.2 (2022-05-17)

Expand Down
8 changes: 6 additions & 2 deletions Castle.Windsor.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30711.63
# Visual Studio Version 17
VisualStudioVersion = 17.7.33913.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Castle.Windsor", "src\Castle.Windsor\Castle.Windsor.csproj", "{5F6A631E-8EB1-4BC1-826D-86D3059945B8}"
EndProject
Expand All @@ -20,9 +20,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Castle Build", "Castle Buil
.gitattributes = .gitattributes
.gitignore = .gitignore
appveyor.yml = appveyor.yml
.github\workflows\build-test-linux.yml = .github\workflows\build-test-linux.yml
.github\workflows\build-test-win.yml = .github\workflows\build-test-win.yml
build.cmd = build.cmd
CHANGELOG.md = CHANGELOG.md
CONTRIBUTING.md = CONTRIBUTING.md
.github\workflows\dotnet-release.yml = .github\workflows\dotnet-release.yml
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ See the [releases](https://github.com/castleproject/Windsor/releases).

## License

Castle Windsor is &copy; 2004-2022 Castle Project. It is free software, and may be redistributed under the terms of the [Apache 2.0](http://opensource.org/licenses/Apache-2.0) license.
Castle Windsor is &copy; 2004-2023 Castle Project. It is free software, and may be redistributed under the terms of the [Apache 2.0](http://opensource.org/licenses/Apache-2.0) license.

## NuGet Preview Feed

Expand All @@ -30,20 +30,16 @@ The following conditional compilation symbols are currently defined for Windsor:

Symbol | .NET 4.6.2 | .NET Standard / 6
----------------------------------- | ------------------ | ------------------
`CASTLE_SERVICES_LOGGING` | :white_check_mark: | :no_entry_sign:
`FEATURE_APPDOMAIN` | :white_check_mark: | :no_entry_sign:
`FEATURE_ASSEMBLIES` | :white_check_mark: | :no_entry_sign:
`FEATURE_EVENTLOG` | :white_check_mark: | :no_entry_sign:
`FEATURE_PERFCOUNTERS`            | :white_check_mark: | :no_entry_sign:
`FEATURE_REMOTING` | :white_check_mark: | :no_entry_sign:
`FEATURE_SECURITY_PERMISSIONS` | :white_check_mark: | :no_entry_sign:
`FEATURE_SERIALIZATION` | :white_check_mark: | :no_entry_sign:
`FEATURE_SYSTEM_CONFIGURATION` | :white_check_mark: | :no_entry_sign:

* `CASTLE_SERVICES_LOGGING` - enables access to `Castle.Services.Logging.log4netIntegration` and `Castle.Services.Logging.NLogIntegration` in the logging facility.
* `FEATURE_APPDOMAIN` - enables support for features that make use of an AppDomain in the host.
* `FEATURE_ASSEMBLIES` - uses `AssemblyName.GetAssemblyName()` and `Assembly.LoadFile()`.
* `FEATURE_EVENTLOG` - uses Castle Core APIs that are based on the Windows Event Log.
* `FEATURE_PERFCOUNTERS` - enables code that uses Windows Performance Counters.
* `FEATURE_REMOTING` - supports remoting on various types including inheriting from `MarshalByRefObject`.
* `FEATURE_SECURITY_PERMISSIONS` - enables the use of CAS and `Security[Critical|SafeCritical|Transparent]`.
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net462'">
<DefineConstants>$(DefineConstants);FEATURE_PERFCOUNTERS;FEATURE_REMOTING;FEATURE_SECURITY_PERMISSIONS;FEATURE_SYSTEM_CONFIGURATION;FEATURE_SERIALIZATION;FEATURE_APPDOMAIN;FEATURE_CODEDOM;FEATURE_ASSEMBLIES;CASTLE_SERVICES_LOGGING;FEATURE_EVENTLOG</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_PERFCOUNTERS;FEATURE_REMOTING;FEATURE_SECURITY_PERMISSIONS;FEATURE_SYSTEM_CONFIGURATION;FEATURE_SERIALIZATION;FEATURE_APPDOMAIN;FEATURE_CODEDOM;FEATURE_ASSEMBLIES</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
71 changes: 40 additions & 31 deletions docs/logging-facility.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,65 @@ Castle Core [provides many logger abstraction implementations](https://github.co

## Registering the facility

:warning: **`LoggerImplementation` enum and the `loggingApi` XML property are deprecated:** Usage of `LogUsing` and `customLoggerFactory` are highly recommended even for Castle Core provided implementations.
### In code

The recommended way of configuring the facility is using code. When specifying custom `ILoggerFactory` or `IExtendedLoggerFactory` you use the following generic overload:

```csharp
container.AddFacility<LoggingFacility>(f => f.LogUsing<CustomLoggerFactory>());
```

For example, using the log4net logger factory with configuration stored in a `log4net.xml` file, the code would look like this:

```csharp
container.AddFacility<LoggingFacility>(f => f.LogUsing<Log4netFactory>().WithConfig("log4net.xml"));
```

#### Built-in logging factories

There are a few helper methods for built-in logging factories:
```csharp
// Null Logger
container.AddFacility<LoggingFacility>(f => f.LogUsingNullLogger());

// Console Logger
container.AddFacility<LoggingFacility>(f => f.LogUsingConsoleLogger());

// Diagnostics Logger
container.AddFacility<LoggingFacility>(f => f.LogUsingDiagnosticsLogger());

// Trace Logger
container.AddFacility<LoggingFacility>(f => f.LogUsingTraceLogger());
```

### Via XML Configuration

Logging facility exposes minimalistic configuration:
It is also possible to configure the facility via XML. For example the same configuration for log4net as above:

```xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<facility
type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging"
loggingApi="null|console|diagnostics|web|nlog|log4net|custom"
customLoggerFactory="type name that implements ILoggerFactory"
configFile="optional config file location" />
customLoggerFactory="Castle.Services.Logging.Log4netIntegration.Log4netFactory, Castle.Services.Logging.Log4netIntegration"
configFile="log4net.xml" />
</configuration>
```

For example to use log4net with logger configuration stored in `log4net.xml` file, you would configure the facility like this:
The full list of configuraation attributes is shown in the following example:

```xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<facility
type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging"
loggingApi="log4net"
configFile="log4net.xml" />
customLoggerFactory="<type of factory>"
configFile="<path to configuration file (optional attribute)>"
loggerLevel="<the loggerLevel (optional attribute)>"
configuredExternally="<boolean value (optional attribute)>" "/>
</configuration>
```

### In code

Recommended way of configuring the facility however, is using code. The facility exposes the same options like via XML.
For example the same configuration for log4net as above, from code would look like this:

```csharp
container.AddFacility<LoggingFacility>(f => f.LogUsing<Log4netFactory>().WithConfig("log4net.xml"));
```

When specifying custom `ILoggerFactory` or `IExtendedLoggerFactory` you use the following generic overload:

```csharp
container.AddFacility<LoggingFacility>(f => f.LogUsing<CustomLoggerFactory>());
```

## Best practices

We recommend that you make logging optional on your components/services. This way you maximize the reusability. For example:
Expand All @@ -66,17 +81,11 @@ using Castle.Core.Logging;

public class CustomerService
{
private ILogger logger = NullLogger.Instance;

public CustomerService()
{
}

public ILogger Logger
{
get { return logger; }
set { logger = value; }
}
public ILogger Logger { get; set; } = NullLogger.Instance;

// ...
}
Expand All @@ -87,4 +96,4 @@ With the approach above, the logger field will never be null. Also, if the loggi
## Required Assemblies

* `Castle.Facilities.Logging.dll` (bundled with Windsor)
* `Castle.Core.dll` (contains the `ILogger` and `ILoggerFactory`)
* `Castle.Core.dll` (contains the `ILogger` and `ILoggerFactory` interfaces; included as a dependency in the Windsor NuGet package)
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.3" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading