From 9b794b5750f85eab37518d957437e73685a06fc4 Mon Sep 17 00:00:00 2001 From: Jevon Date: Wed, 5 Oct 2022 23:26:52 +0100 Subject: [PATCH 01/15] Rework LoggingFacility to remove obsolete code and LoggerImplementation --- CHANGELOG.md | 1 + .../BuiltInLoggingFactoryExtensions.cs | 30 +++ .../LoggerImplementation.cs | 41 --- .../LoggingFacility.cs | 244 +++--------------- 4 files changed, 74 insertions(+), 242 deletions(-) create mode 100644 src/Castle.Facilities.Logging/BuiltInLoggingFactoryExtensions.cs delete mode 100644 src/Castle.Facilities.Logging/LoggerImplementation.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index c5d4ab000c..97acbf8fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Bugfixes: 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) +- Obsolete components in Castle.Facilities.Logging have been removed. Extensions methods for built-in logging factories have been added. (@Jevonius, #616) ## 5.1.2 (2022-05-17) diff --git a/src/Castle.Facilities.Logging/BuiltInLoggingFactoryExtensions.cs b/src/Castle.Facilities.Logging/BuiltInLoggingFactoryExtensions.cs new file mode 100644 index 0000000000..8a9f86ff8e --- /dev/null +++ b/src/Castle.Facilities.Logging/BuiltInLoggingFactoryExtensions.cs @@ -0,0 +1,30 @@ +// Copyright 2022 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.Facilities.Logging +{ + using Castle.Core.Logging; + + public static class BuiltInLoggingFactoryExtensions + { + public static LoggingFacility LogUsingNullLogger(this LoggingFacility loggingFacility) => loggingFacility.LogUsing(); + public static LoggingFacility LogUsingConsoleLogger(this LoggingFacility loggingFacility) => loggingFacility.LogUsing(); + +#if NET6_0_OR_GREATER + [System.Runtime.Versioning.SupportedOSPlatform("windows")] +#endif + public static LoggingFacility LogUsingDiagnosticsLogger(this LoggingFacility loggingFacility) => loggingFacility.LogUsing(); + public static LoggingFacility LogUsingTraceLogger(this LoggingFacility loggingFacility) => loggingFacility.LogUsing(); + } +} diff --git a/src/Castle.Facilities.Logging/LoggerImplementation.cs b/src/Castle.Facilities.Logging/LoggerImplementation.cs deleted file mode 100644 index 90b99a3ddb..0000000000 --- a/src/Castle.Facilities.Logging/LoggerImplementation.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Castle.Facilities.Logging -{ - using System; - - using Castle.Core.Logging; - - /// - /// The supported implementations. - /// - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public enum LoggerImplementation - { - Custom, - Null, - Console, -#if FEATURE_EVENTLOG - Diagnostics, -#endif -#if CASTLE_SERVICES_LOGGING - NLog, - Log4net, - ExtendedNLog, - ExtendedLog4net, -#endif - Trace - } -} \ No newline at end of file diff --git a/src/Castle.Facilities.Logging/LoggingFacility.cs b/src/Castle.Facilities.Logging/LoggingFacility.cs index 02c228e5de..dbe868ce90 100644 --- a/src/Castle.Facilities.Logging/LoggingFacility.cs +++ b/src/Castle.Facilities.Logging/LoggingFacility.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#pragma warning disable CS0618 // Suppress LoggerImplementation is obsolete warning until removed - namespace Castle.Facilities.Logging { using System; @@ -32,34 +30,12 @@ namespace Castle.Facilities.Logging /// public class LoggingFacility : AbstractFacility { -#if CASTLE_SERVICES_LOGGING //Castle.Services.Logging.Log4netIntegration and Castle.Services.Logging.NLogIntegration are not available for .NET Standard - private static readonly String ExtendedLog4NetLoggerFactoryTypeName = - "Castle.Services.Logging.Log4netIntegration.ExtendedLog4netFactory," + - "Castle.Services.Logging.Log4netIntegration,Version=4.0.0.0, Culture=neutral," + - "PublicKeyToken=407dd0808d44fbdc"; - - private static readonly String ExtendedNLogLoggerFactoryTypeName = - "Castle.Services.Logging.NLogIntegration.ExtendedNLogFactory," + - "Castle.Services.Logging.NLogIntegration,Version=4.0.0.0, Culture=neutral," + - "PublicKeyToken=407dd0808d44fbdc"; - - private static readonly String Log4NetLoggerFactoryTypeName = - "Castle.Services.Logging.Log4netIntegration.Log4netFactory," + - "Castle.Services.Logging.Log4netIntegration,Version=4.0.0.0, Culture=neutral," + - "PublicKeyToken=407dd0808d44fbdc"; - - private static readonly String NLogLoggerFactoryTypeName = - "Castle.Services.Logging.NLogIntegration.NLogFactory," + - "Castle.Services.Logging.NLogIntegration,Version=4.0.0.0, Culture=neutral," + - "PublicKeyToken=407dd0808d44fbdc"; -#endif private readonly string customLoggerFactoryTypeName; private string configFileName; private ITypeConverter converter; - private LoggerImplementation? loggerImplementation; - private Type loggingFactoryType; + private Type loggerFactoryType; private LoggerLevel? loggerLevel; private ILoggerFactory loggerFactory; private string logName; @@ -72,73 +48,28 @@ public LoggingFacility() { } - /// - /// Initializes a new instance of the class. - /// - /// The LoggerImplementation that should be used - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility(LoggerImplementation loggingApi) : this(loggingApi, null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The LoggerImplementation that should be used - /// The configuration file that should be used by the chosen LoggerImplementation - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility(LoggerImplementation loggingApi, string configFile) : this(loggingApi, null, configFile) - { - } - /// /// Initializes a new instance of the class using a custom LoggerImplementation /// - /// The configuration file that should be used by the chosen LoggerImplementation /// The type name of the type of the custom logger factory. - public LoggingFacility(string customLoggerFactory, string configFile) - : this(LoggerImplementation.Custom, customLoggerFactory, configFile) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The LoggerImplementation that should be used /// The configuration file that should be used by the chosen LoggerImplementation - /// The type name of the type of the custom logger factory. (only used when loggingApi is set to LoggerImplementation.Custom) - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility(LoggerImplementation loggingApi, string customLoggerFactory, string configFile) + public LoggingFacility(string customLoggerFactory, string configFile) { - loggerImplementation = loggingApi; customLoggerFactoryTypeName = customLoggerFactory; configFileName = configFile; } - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility LogUsing(LoggerImplementation loggingApi) - { - if (loggingApi == LoggerImplementation.Custom) - { - throw new FacilityException("To use custom logger use LogUsing() method."); - } - loggerImplementation = loggingApi; - return this; - } - public LoggingFacility LogUsing() where TLoggerFactory : ILoggerFactory { - loggerImplementation = LoggerImplementation.Custom; - loggingFactoryType = typeof(TLoggerFactory); + loggerFactoryType = typeof(TLoggerFactory); return this; } public LoggingFacility LogUsing(TLoggerFactory loggerFactory) where TLoggerFactory : ILoggerFactory { - loggerImplementation = LoggerImplementation.Custom; - loggingFactoryType = typeof(TLoggerFactory); + loggerFactoryType = typeof(TLoggerFactory); this.loggerFactory = loggerFactory; return this; } @@ -151,9 +82,7 @@ public LoggingFacility ConfiguredExternally() public LoggingFacility WithConfig(string configFile) { - if (configFile == null) throw new ArgumentNullException(nameof(configFile)); - - configFileName = configFile; + configFileName = configFile ?? throw new ArgumentNullException(nameof(configFile)); return this; } @@ -169,32 +98,6 @@ public LoggingFacility ToLog(string name) return this; } -#if CASTLE_SERVICES_LOGGING - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility UseLog4Net() - { - return LogUsing(LoggerImplementation.Log4net); - } - - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility UseLog4Net(string configFile) - { - return UseLog4Net().WithConfig(configFile); - } - - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility UseNLog() - { - return LogUsing(LoggerImplementation.NLog); - } - - [Obsolete("A logger factory implementation type should be provided via LogUsing(), this will be removed in the future.")] - public LoggingFacility UseNLog(string configFile) - { - return LogUsing(LoggerImplementation.NLog).WithConfig(configFile); - } -#endif - #if FEATURE_SYSTEM_CONFIGURATION /// /// loads configuration from current AppDomain's config file (aka web.config/app.config) @@ -212,30 +115,54 @@ protected override void Init() SetUpTypeConverter(); if (loggerFactory == null) { - loggerFactory = ReadConfigurationAndCreateLoggerFactory(); + ReadConfigurationAndCreateLoggerFactory(); } RegisterLoggerFactory(loggerFactory); RegisterDefaultILogger(loggerFactory); RegisterSubResolver(loggerFactory); } - private ILoggerFactory CreateProperLoggerFactory(LoggerImplementation loggerApi) + private void ReadConfigurationAndCreateLoggerFactory() { - var loggerFactoryType = GetLoggingFactoryType(loggerApi); - Debug.Assert(loggerFactoryType != null, "loggerFactoryType != null"); + if (loggerFactoryType == null) + { + loggerFactoryType = ReadCustomLoggerType(); + } + EnsureIsValidLoggerFactoryType(); + CreateProperLoggerFactory(); + } - var ctorArgs = GetLoggingFactoryArguments(loggerFactoryType); - return loggerFactoryType.CreateInstance(ctorArgs); + private Type ReadCustomLoggerType() + { + if (FacilityConfig != null) + { + var customLoggerType = FacilityConfig.Attributes["customLoggerFactory"]; + if (string.IsNullOrEmpty(customLoggerType) == false) + { + return converter.PerformConversion(customLoggerType); + } + } + if (customLoggerFactoryTypeName != null) + { + return converter.PerformConversion(customLoggerFactoryTypeName); + } + return typeof(NullLogFactory); } - private Type EnsureIsValidLoggerFactoryType(Type loggerFactoryType) + private void EnsureIsValidLoggerFactoryType() { - if (loggerFactoryType.Is() || loggerFactoryType.Is()) + if (!loggerFactoryType.Is()) { - return loggerFactoryType; + throw new FacilityException($"The specified type '{loggerFactoryType}' does not implement ILoggerFactory."); } - throw new FacilityException("The specified type '" + loggerFactoryType + - "' does not implement either ILoggerFactory or IExtendedLoggerFactory."); + } + + private void CreateProperLoggerFactory() + { + Debug.Assert(loggerFactoryType != null, "loggerFactoryType != null"); + + var ctorArgs = GetLoggingFactoryArguments(); + loggerFactory = loggerFactoryType.CreateInstance(ctorArgs); } private string GetConfigFile() @@ -252,12 +179,7 @@ private string GetConfigFile() return null; } - private Type GetCustomLoggerType() - { - return EnsureIsValidLoggerFactoryType(ReadCustomLoggerType()); - } - - private object[] GetLoggingFactoryArguments(Type loggerFactoryType) + private object[] GetLoggingFactoryArguments() { const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public; @@ -294,7 +216,7 @@ private object[] GetLoggingFactoryArguments(Type loggerFactoryType) { return new object[0]; } - throw new FacilityException("No support constructor found for logging type " + loggerFactoryType); + throw new FacilityException($"No support constructor found for logging type '{loggerFactoryType}'"); } private bool IsConfiguredExternally() @@ -331,84 +253,6 @@ private bool IsConfiguredExternally() return null; } - private Type GetLoggingFactoryType(LoggerImplementation loggerApi) - { - switch (loggerApi) - { - case LoggerImplementation.Custom: - return GetCustomLoggerType(); - case LoggerImplementation.Null: - return typeof(NullLogFactory); - case LoggerImplementation.Console: - return typeof(ConsoleFactory); -#if FEATURE_EVENTLOG //has dependency on Castle.Core.Logging.DiagnosticsLoggerFactory - case LoggerImplementation.Diagnostics: - return typeof(DiagnosticsLoggerFactory); -#endif - case LoggerImplementation.Trace: - return typeof(TraceLoggerFactory); -#if CASTLE_SERVICES_LOGGING - case LoggerImplementation.NLog: - return converter.PerformConversion(NLogLoggerFactoryTypeName); - case LoggerImplementation.Log4net: - return converter.PerformConversion(Log4NetLoggerFactoryTypeName); - case LoggerImplementation.ExtendedLog4net: - return converter.PerformConversion(ExtendedLog4NetLoggerFactoryTypeName); - case LoggerImplementation.ExtendedNLog: - return converter.PerformConversion(ExtendedNLogLoggerFactoryTypeName); -#endif - default: - { - throw new FacilityException("An invalid loggingApi was specified: " + loggerApi); - } - } - } - - private ILoggerFactory ReadConfigurationAndCreateLoggerFactory() - { - var logApi = ReadLoggingApi(); - var loggerFactory = CreateProperLoggerFactory(logApi); - return loggerFactory; - } - - private Type ReadCustomLoggerType() - { - if (FacilityConfig != null) - { - var customLoggerType = FacilityConfig.Attributes["customLoggerFactory"]; - if (string.IsNullOrEmpty(customLoggerType) == false) - { - return converter.PerformConversion(customLoggerType); - } - } - if (customLoggerFactoryTypeName != null) - { - return converter.PerformConversion(customLoggerFactoryTypeName); - } - if (loggingFactoryType != null) - { - return loggingFactoryType; - } - var message = "If you specify loggingApi='custom' " + - "then you must use the attribute customLoggerFactory to inform the " + - "type name of the custom logger factory"; - - throw new FacilityException(message); - } - - private LoggerImplementation ReadLoggingApi() - { - if (FacilityConfig != null) - { - var configLoggingApi = FacilityConfig.Attributes["loggingApi"]; - if (string.IsNullOrEmpty(configLoggingApi) == false) - { - return converter.PerformConversion(configLoggingApi); - } - } - return loggerImplementation.GetValueOrDefault(LoggerImplementation.Console); - } - private void RegisterDefaultILogger(ILoggerFactory factory) { if (factory is IExtendedLoggerFactory) @@ -454,5 +298,3 @@ private void SetUpTypeConverter() } } } - -#pragma warning restore CS0618 // Suppress LoggerImplementation is obsolete warning until removed From 52e224a6e64852af21793133afc16fb3fb2c5097 Mon Sep 17 00:00:00 2001 From: Jevon Date: Wed, 5 Oct 2022 23:38:21 +0100 Subject: [PATCH 02/15] Remove CASTLE_SERVICES_LOGGING FEATURE_EVENTLOG conditional compilation symbols as they're no longer required The tests now work across all target frameworks. --- README.md | 4 ---- buildscripts/common.props | 2 +- src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj | 10 +++++----- src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs | 6 +----- .../LoggingFacility/Classes/CustomLog4NetFactory.cs | 5 +---- .../LoggingFacility/CustomFacilityTests.cs | 7 ++----- .../LoggingFacility/ExtendedLog4NetFacilityTestCase.cs | 4 +--- .../LoggingFacility/ExtendedNLogFacilityTests.cs | 4 +--- .../Log4NetFacilityLognameOverrideTests.cs | 4 +--- .../LoggingFacility/Log4NetFacilityTests.cs | 4 +--- .../LoggingFacility/NLogFacilityTests.cs | 4 +--- 11 files changed, 15 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index fffc48eced..f0b702a09f 100644 --- a/README.md +++ b/README.md @@ -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]`. diff --git a/buildscripts/common.props b/buildscripts/common.props index 511e19191b..ca760b6ba2 100644 --- a/buildscripts/common.props +++ b/buildscripts/common.props @@ -36,7 +36,7 @@ - $(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);FEATURE_PERFCOUNTERS;FEATURE_REMOTING;FEATURE_SECURITY_PERMISSIONS;FEATURE_SYSTEM_CONFIGURATION;FEATURE_SERIALIZATION;FEATURE_APPDOMAIN;FEATURE_CODEDOM;FEATURE_ASSEMBLIES diff --git a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj index 4a9a1b29fa..2d9c661be7 100644 --- a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj +++ b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj @@ -44,16 +44,16 @@ + + - - - - - + + + diff --git a/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs b/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs index 152be5c4ad..0fb1a91578 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,10 +16,8 @@ namespace Castle.Facilities.Logging.Tests { using Castle.Core.Logging; using Castle.MicroKernel.SubSystems.Configuration; -#if CASTLE_SERVICES_LOGGING using Castle.Services.Logging.Log4netIntegration; using Castle.Services.Logging.NLogIntegration; -#endif using Castle.Windsor; /// @@ -41,7 +39,6 @@ protected virtual IWindsorContainer CreateConfiguredContainer() protected string GetConfigFile() where TLoggerFactory : ILoggerFactory { -#if CASTLE_SERVICES_LOGGING if (typeof(TLoggerFactory) == typeof(Log4netFactory) || typeof(TLoggerFactory) == typeof(ExtendedLog4netFactory)) { @@ -52,7 +49,6 @@ protected string GetConfigFile() { return "LoggingFacility\\NLog.facilities.test.config"; } -#endif return string.Empty; } } diff --git a/src/Castle.Windsor.Tests/LoggingFacility/Classes/CustomLog4NetFactory.cs b/src/Castle.Windsor.Tests/LoggingFacility/Classes/CustomLog4NetFactory.cs index 64bd4dcba8..cc44eefe0b 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/Classes/CustomLog4NetFactory.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/Classes/CustomLog4NetFactory.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2011 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - -#if CASTLE_SERVICES_LOGGING namespace CastleTests.LoggingFacility.Tests.Classes { using System; @@ -43,4 +41,3 @@ public override ILogger Create(String name, LoggerLevel level) } } } -#endif \ No newline at end of file diff --git a/src/Castle.Windsor.Tests/LoggingFacility/CustomFacilityTests.cs b/src/Castle.Windsor.Tests/LoggingFacility/CustomFacilityTests.cs index 031fde6cd8..fdb6d00df6 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/CustomFacilityTests.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/CustomFacilityTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2011 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if CASTLE_SERVICES_LOGGING namespace CastleTests.LoggingFacility { using Castle.Core.Logging; @@ -40,8 +39,7 @@ public void ReadCustomFacilityConfigFromXML() string.Format( @" - @@ -54,4 +52,3 @@ public void ReadCustomFacilityConfigFromXML() } } } -#endif \ No newline at end of file diff --git a/src/Castle.Windsor.Tests/LoggingFacility/ExtendedLog4NetFacilityTestCase.cs b/src/Castle.Windsor.Tests/LoggingFacility/ExtendedLog4NetFacilityTestCase.cs index fae9c008ac..650330cf2f 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/ExtendedLog4NetFacilityTestCase.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/ExtendedLog4NetFacilityTestCase.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if CASTLE_SERVICES_LOGGING namespace Castle.Facilities.Logging.Tests { using System; @@ -101,4 +100,3 @@ public void ContextTest() } } } -#endif diff --git a/src/Castle.Windsor.Tests/LoggingFacility/ExtendedNLogFacilityTests.cs b/src/Castle.Windsor.Tests/LoggingFacility/ExtendedNLogFacilityTests.cs index c7ed0d55e9..14bc7c7090 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/ExtendedNLogFacilityTests.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/ExtendedNLogFacilityTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if CASTLE_SERVICES_LOGGING namespace Castle.Facilities.Logging.Tests { using System; @@ -87,4 +86,3 @@ public void ContextTest() } } } -#endif diff --git a/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityLognameOverrideTests.cs b/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityLognameOverrideTests.cs index ffdbd63a86..4a897132df 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityLognameOverrideTests.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityLognameOverrideTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if CASTLE_SERVICES_LOGGING namespace Castle.Facilities.Logging.Tests { using System; @@ -65,4 +64,3 @@ public void OverrideTest() } } } -#endif \ No newline at end of file diff --git a/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityTests.cs b/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityTests.cs index a286c0f1bb..aabb6ba32b 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityTests.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/Log4NetFacilityTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if CASTLE_SERVICES_LOGGING namespace Castle.Facilities.Logging.Tests { using System; @@ -66,4 +65,3 @@ public void SimpleTest() } } } -#endif diff --git a/src/Castle.Windsor.Tests/LoggingFacility/NLogFacilityTests.cs b/src/Castle.Windsor.Tests/LoggingFacility/NLogFacilityTests.cs index e8f17412ee..d739f77248 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/NLogFacilityTests.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/NLogFacilityTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2017 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if CASTLE_SERVICES_LOGGING namespace Castle.Facilities.Logging.Tests { using System; @@ -65,4 +64,3 @@ public void SimpleTest() } } } -#endif \ No newline at end of file From 1e4dd3c952fc04fa8e1e137687d035b727111fc9 Mon Sep 17 00:00:00 2001 From: Jevon Date: Thu, 6 Oct 2022 00:04:22 +0100 Subject: [PATCH 03/15] Remove explicit references to Microsoft.TestPlatform.ObjectModel --- .../Castle.Facilities.AspNet.Mvc.Tests.csproj | 1 - .../Castle.Facilities.AspNet.SystemWeb.Tests.csproj | 1 - .../Castle.Facilities.AspNet.WebApi.Tests.csproj | 1 - .../Castle.Facilities.WcfIntegration.Tests.csproj | 1 - src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj | 4 ---- 5 files changed, 8 deletions(-) diff --git a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj index 5512330dbe..04611c416f 100644 --- a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj +++ b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj @@ -17,7 +17,6 @@ - diff --git a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj index fef2d0db98..2cadbd2bd0 100644 --- a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj +++ b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj @@ -22,7 +22,6 @@ - diff --git a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj index 4bf6854af9..ac0d3bf21f 100644 --- a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj +++ b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj @@ -17,7 +17,6 @@ - diff --git a/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj b/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj index 3d0cf68e78..11b5401dc0 100644 --- a/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj +++ b/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj index 2d9c661be7..ea32df6401 100644 --- a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj +++ b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj @@ -50,10 +50,6 @@ - - - - From c42781e6d6c8848f0762bcbb0b7ecd0f54a9180f Mon Sep 17 00:00:00 2001 From: Jevon Date: Thu, 6 Oct 2022 13:45:56 +0100 Subject: [PATCH 04/15] Revert removal of `Microsoft.TestPlatform.ObjectModel.11.0.0` This works around an issue with NUnit3TestAdapter private referencing this version, stopping assembly binding redirects, and Windsor struggling to call `GetExportedTypes` as a result. --- .../Castle.Facilities.AspNet.Mvc.Tests.csproj | 3 ++- .../Castle.Facilities.AspNet.SystemWeb.Tests.csproj | 7 ++++--- .../Castle.Facilities.AspNet.WebApi.Tests.csproj | 3 ++- src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj index 04611c416f..ccb0686472 100644 --- a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj +++ b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj @@ -15,8 +15,9 @@ - + + diff --git a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj index 2cadbd2bd0..76f9f3266d 100644 --- a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj +++ b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj @@ -19,9 +19,10 @@ - - - + + + + diff --git a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj index ac0d3bf21f..af37968903 100644 --- a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj +++ b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj @@ -15,8 +15,9 @@ - + + diff --git a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj index ea32df6401..474f70187f 100644 --- a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj +++ b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj @@ -48,7 +48,10 @@ - + + + + From f02184092c53e59147d00be945f17a51bbf66cbf Mon Sep 17 00:00:00 2001 From: Jevon Date: Thu, 6 Oct 2022 20:12:21 +0100 Subject: [PATCH 05/15] Update documentation to reflect changes to logging facility --- docs/logging-facility.md | 71 ++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/docs/logging-facility.md b/docs/logging-facility.md index aa793e9cbe..b2d2f15e15 100644 --- a/docs/logging-facility.md +++ b/docs/logging-facility.md @@ -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(f => f.LogUsing()); +``` + +For example, using the log4net logger factory with configuration stored in a `log4net.xml` file, the code would look like this: + +```csharp +container.AddFacility(f => f.LogUsing().WithConfig("log4net.xml")); +``` + +#### Built-in logging factories + +There are a few helper methods for built-in logging factories: +```csharp +// Null Logger +container.AddFacility(f => f.LogUsingNullLogger()); + +// Console Logger +container.AddFacility(f => f.LogUsingConsoleLogger()); + +// Diagnostics Logger +container.AddFacility(f => f.LogUsingDiagnosticsLogger()); + +// Trace Logger +container.AddFacility(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 + customLoggerFactory="Castle.Services.Logging.Log4netIntegration.Log4netFactory, Castle.Services.Logging.Log4netIntegration" + configFile="log4net.xml" /> ``` -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 + customLoggerFactory="" + configFile="" + loggerLevel="" + configuredExternally="" "/> ``` -### 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(f => f.LogUsing().WithConfig("log4net.xml")); -``` - -When specifying custom `ILoggerFactory` or `IExtendedLoggerFactory` you use the following generic overload: - -```csharp -container.AddFacility(f => f.LogUsing()); -``` - ## Best practices We recommend that you make logging optional on your components/services. This way you maximize the reusability. For example: @@ -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; // ... } @@ -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) From fa1436e76c26d6f8a9df39df032e998f47d3c156 Mon Sep 17 00:00:00 2001 From: Jonathon Rossi Date: Thu, 20 Jul 2023 22:17:41 +1000 Subject: [PATCH 06/15] Update CHANGELOG.md --- CHANGELOG.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97acbf8fd5..3f7b008ea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +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) -- Obsolete components in Castle.Facilities.Logging have been removed. Extensions methods for built-in logging factories have been added. (@Jevonius, #616) +- 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` 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) From 215f88d5ef94e0caf4948e212d036dc83722027a Mon Sep 17 00:00:00 2001 From: Jonathon Rossi Date: Thu, 20 Jul 2023 22:18:40 +1000 Subject: [PATCH 07/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0b702a09f..9739ab5c48 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ See the [releases](https://github.com/castleproject/Windsor/releases). ## License -Castle Windsor is © 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 © 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 From 14c184400455221b0d9ee8ac38fa6cd27a18be4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schultz=20Madsen?= Date: Wed, 30 Nov 2022 06:48:06 +0000 Subject: [PATCH 08/15] Adding Github Actions build script for easy testing. --- .github/workflows/dotnet-ubuntu-pr.yml | 40 ++++++++++++++++++++++++++ .github/workflows/dotnet-ubuntu.yml | 40 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/dotnet-ubuntu-pr.yml create mode 100644 .github/workflows/dotnet-ubuntu.yml diff --git a/.github/workflows/dotnet-ubuntu-pr.yml b/.github/workflows/dotnet-ubuntu-pr.yml new file mode 100644 index 0000000000..67e421444a --- /dev/null +++ b/.github/workflows/dotnet-ubuntu-pr.yml @@ -0,0 +1,40 @@ +name: .NET Ubuntu PR + +on: + pull_request: + branches: [ master, main ] + paths-ignore: + - '**.md' + - '.github/**' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + - 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 + - name: Castle.Windsor.Tests + run: dotnet test src/Castle.Windsor.Tests + - name: Castle.Windsor.Extensions.DependencyInjection.Tests + run: dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests + - name: Castle.Facilities.AspNetCore.Tests + run: dotnet test src/Castle.Facilities.AspNetCore.Tests + - name: Castle.Facilities.AspNet.SystemWeb.Tests + run: dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests + - name: Castle.Facilities.AspNet.Mvc.Tests + run: dotnet test src/Castle.Facilities.AspNet.Mvc.Tests + - name: Castle.Facilities.AspNet.WebApi.Tests + run: dotnet test src/Castle.Facilities.AspNet.WebApi.Tests + - name: Castle.Facilities.WcfIntegration.Tests + run: dotnet test src/Castle.Facilities.WcfIntegration.Tests diff --git a/.github/workflows/dotnet-ubuntu.yml b/.github/workflows/dotnet-ubuntu.yml new file mode 100644 index 0000000000..3ba164092a --- /dev/null +++ b/.github/workflows/dotnet-ubuntu.yml @@ -0,0 +1,40 @@ +name: .NET Ubuntu + +on: + push: + branches: [ master, main ] + paths-ignore: + - '**.md' + - '.github/**' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + - 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 + - name: Castle.Windsor.Tests + run: dotnet test src/Castle.Windsor.Tests + - name: Castle.Windsor.Extensions.DependencyInjection.Tests + run: dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests + - name: Castle.Facilities.AspNetCore.Tests + run: dotnet test src/Castle.Facilities.AspNetCore.Tests + - name: Castle.Facilities.AspNet.SystemWeb.Tests + run: dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests + - name: Castle.Facilities.AspNet.Mvc.Tests + run: dotnet test src/Castle.Facilities.AspNet.Mvc.Tests + - name: Castle.Facilities.AspNet.WebApi.Tests + run: dotnet test src/Castle.Facilities.AspNet.WebApi.Tests + - name: Castle.Facilities.WcfIntegration.Tests + run: dotnet test src/Castle.Facilities.WcfIntegration.Tests From e5d1c513540d43c95a963f1b5a15a92201cf7f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schultz=20Madsen?= Date: Wed, 30 Nov 2022 09:07:09 +0000 Subject: [PATCH 09/15] Changing PackageId so we can release a new Nuget under Microting namespace. Adding release script. --- .github/workflows/dotnet-release.yml | 46 +++++++++++++++++++ .../Castle.Facilities.AspNetCore.csproj | 2 +- .../Castle.Facilities.Logging.csproj | 2 +- ...dsor.Extensions.DependencyInjection.csproj | 2 +- .../Castle.Windsor.Extensions.Hosting.csproj | 2 +- src/Castle.Windsor/Castle.Windsor.csproj | 2 +- 6 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/dotnet-release.yml diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml new file mode 100644 index 0000000000..9351797e47 --- /dev/null +++ b/.github/workflows/dotnet-release.yml @@ -0,0 +1,46 @@ +name: .NET Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build-ubuntu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET 7.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build Release + run: dotnet build Castle.Windsor.sln -c Release + - name: Castle.Windsor.Tests + run: dotnet test src/Castle.Windsor.Tests + - name: Castle.Windsor.Extensions.DependencyInjection.Tests + run: dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests + - name: Castle.Facilities.AspNetCore.Tests + run: dotnet test src/Castle.Facilities.AspNetCore.Tests + deploy: + needs: build-ubuntu + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 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 --configuration Release + - name: Pack + run: dotnet pack Castle.Windsor.sln -c Release -o ./artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + - name: Push generated Rebus package to GitHub registry + run: dotnet nuget push /home/runner/work/Windsor/Windsor/artifacts/Microting.Castle.Windsor.${{ steps.get_version.outputs.VERSION }}.nupkg -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file diff --git a/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj b/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj index 69d652dbda..2060f59de6 100644 --- a/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj +++ b/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj @@ -8,7 +8,7 @@ true - Castle.Facilities.AspNetCore + Microting.Castle.Facilities.AspNetCore Castle Windsor ASP.NET Core facility Castle Windsor ASP.NET Core facility lets you easily add windsor to aspnet core apps. castle, windsor, inversionOfControl, DependencyInjection, aspnet, core diff --git a/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj b/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj index ba41b52042..c44fa6f6c6 100644 --- a/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj +++ b/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj @@ -8,7 +8,7 @@ true - Castle.LoggingFacility + Microting.Castle.LoggingFacility Castle Windsor logging facility Castle Windsor logging facility lets you easily inject loggers into your components. It offers integration with most popular 3rd party logging frameworks like log4net, NLog and Serilog (see Castle Core docs). castle, windsor, inversionOfControl, DependencyInjection, logging, log4net, nlog diff --git a/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj b/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj index 39e5541003..f5fee62408 100644 --- a/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj +++ b/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj @@ -9,7 +9,7 @@ true - Castle.Windsor.Extensions.DependencyInjection + Microting.Castle.Windsor.Extensions.DependencyInjection Castle Windsor extension for .NET Extensions DependencyInjection Allows to use Castle Windsor as a container using IServiceProvider castle, windsor, inversionOfControl, DependencyInjection, aspnet, core diff --git a/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj b/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj index 88fb0f84d6..2974da7ef8 100644 --- a/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj +++ b/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj @@ -9,7 +9,7 @@ true - Castle.Windsor.Extensions.Hosting + Microting.Castle.Windsor.Extensions.Hosting Castle Windsor extension for .NET Extensions Hosting Allows to use Castle Windsor as a container using IServiceProvider castle, windsor, inversionOfControl, DependencyInjection, aspnet, core diff --git a/src/Castle.Windsor/Castle.Windsor.csproj b/src/Castle.Windsor/Castle.Windsor.csproj index f5acdcc0be..661805cc01 100644 --- a/src/Castle.Windsor/Castle.Windsor.csproj +++ b/src/Castle.Windsor/Castle.Windsor.csproj @@ -8,7 +8,7 @@ true - Castle.Windsor + Microting.Castle.Windsor Castle Windsor Castle Windsor is best of breed, mature Inversion of Control container available for .NET. castle, windsor, inversionOfControl, DependencyInjection From 66643afbbd39fffb328b75dc7e119382ec283e93 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Thu, 20 Jul 2023 12:26:40 +0200 Subject: [PATCH 10/15] Revert package id changes --- .github/workflows/dotnet-release.yml | 2 +- .../Castle.Facilities.AspNetCore.csproj | 2 +- src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj | 2 +- .../Castle.Windsor.Extensions.DependencyInjection.csproj | 2 +- .../Castle.Windsor.Extensions.Hosting.csproj | 2 +- src/Castle.Windsor/Castle.Windsor.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 9351797e47..3234b47ffc 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -43,4 +43,4 @@ jobs: - name: Pack run: dotnet pack Castle.Windsor.sln -c Release -o ./artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} - name: Push generated Rebus package to GitHub registry - run: dotnet nuget push /home/runner/work/Windsor/Windsor/artifacts/Microting.Castle.Windsor.${{ steps.get_version.outputs.VERSION }}.nupkg -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file + run: dotnet nuget push /home/runner/work/Windsor/Windsor/artifacts/Castle.Windsor.${{ steps.get_version.outputs.VERSION }}.nupkg -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file diff --git a/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj b/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj index 2060f59de6..69d652dbda 100644 --- a/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj +++ b/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj @@ -8,7 +8,7 @@ true - Microting.Castle.Facilities.AspNetCore + Castle.Facilities.AspNetCore Castle Windsor ASP.NET Core facility Castle Windsor ASP.NET Core facility lets you easily add windsor to aspnet core apps. castle, windsor, inversionOfControl, DependencyInjection, aspnet, core diff --git a/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj b/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj index c44fa6f6c6..ba41b52042 100644 --- a/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj +++ b/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj @@ -8,7 +8,7 @@ true - Microting.Castle.LoggingFacility + Castle.LoggingFacility Castle Windsor logging facility Castle Windsor logging facility lets you easily inject loggers into your components. It offers integration with most popular 3rd party logging frameworks like log4net, NLog and Serilog (see Castle Core docs). castle, windsor, inversionOfControl, DependencyInjection, logging, log4net, nlog diff --git a/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj b/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj index f5fee62408..39e5541003 100644 --- a/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj +++ b/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj @@ -9,7 +9,7 @@ true - Microting.Castle.Windsor.Extensions.DependencyInjection + Castle.Windsor.Extensions.DependencyInjection Castle Windsor extension for .NET Extensions DependencyInjection Allows to use Castle Windsor as a container using IServiceProvider castle, windsor, inversionOfControl, DependencyInjection, aspnet, core diff --git a/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj b/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj index 2974da7ef8..88fb0f84d6 100644 --- a/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj +++ b/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj @@ -9,7 +9,7 @@ true - Microting.Castle.Windsor.Extensions.Hosting + Castle.Windsor.Extensions.Hosting Castle Windsor extension for .NET Extensions Hosting Allows to use Castle Windsor as a container using IServiceProvider castle, windsor, inversionOfControl, DependencyInjection, aspnet, core diff --git a/src/Castle.Windsor/Castle.Windsor.csproj b/src/Castle.Windsor/Castle.Windsor.csproj index 661805cc01..f5acdcc0be 100644 --- a/src/Castle.Windsor/Castle.Windsor.csproj +++ b/src/Castle.Windsor/Castle.Windsor.csproj @@ -8,7 +8,7 @@ true - Microting.Castle.Windsor + Castle.Windsor Castle Windsor Castle Windsor is best of breed, mature Inversion of Control container available for .NET. castle, windsor, inversionOfControl, DependencyInjection From 4a027ee6b297b099ef3f12a85484eef8e20e7e61 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Thu, 20 Jul 2023 12:29:36 +0200 Subject: [PATCH 11/15] Apply action renaming --- .github/workflows/dotnet-ubuntu.yml | 40 ------------------- .../{dotnet-ubuntu-pr.yml => dotnet.yml} | 6 ++- 2 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/dotnet-ubuntu.yml rename .github/workflows/{dotnet-ubuntu-pr.yml => dotnet.yml} (94%) diff --git a/.github/workflows/dotnet-ubuntu.yml b/.github/workflows/dotnet-ubuntu.yml deleted file mode 100644 index 3ba164092a..0000000000 --- a/.github/workflows/dotnet-ubuntu.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: .NET Ubuntu - -on: - push: - branches: [ master, main ] - paths-ignore: - - '**.md' - - '.github/**' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET 6.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - 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 - - name: Castle.Windsor.Tests - run: dotnet test src/Castle.Windsor.Tests - - name: Castle.Windsor.Extensions.DependencyInjection.Tests - run: dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests - - name: Castle.Facilities.AspNetCore.Tests - run: dotnet test src/Castle.Facilities.AspNetCore.Tests - - name: Castle.Facilities.AspNet.SystemWeb.Tests - run: dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests - - name: Castle.Facilities.AspNet.Mvc.Tests - run: dotnet test src/Castle.Facilities.AspNet.Mvc.Tests - - name: Castle.Facilities.AspNet.WebApi.Tests - run: dotnet test src/Castle.Facilities.AspNet.WebApi.Tests - - name: Castle.Facilities.WcfIntegration.Tests - run: dotnet test src/Castle.Facilities.WcfIntegration.Tests diff --git a/.github/workflows/dotnet-ubuntu-pr.yml b/.github/workflows/dotnet.yml similarity index 94% rename from .github/workflows/dotnet-ubuntu-pr.yml rename to .github/workflows/dotnet.yml index 67e421444a..d373e4b5b9 100644 --- a/.github/workflows/dotnet-ubuntu-pr.yml +++ b/.github/workflows/dotnet.yml @@ -1,6 +1,10 @@ -name: .NET Ubuntu PR +name: .NET CI on: + push: + paths-ignore: + - '**.md' + - '.github/**' pull_request: branches: [ master, main ] paths-ignore: From 4f778ffa40e252f615f4c2bd07f9564b08edd449 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Thu, 20 Jul 2023 15:17:05 +0200 Subject: [PATCH 12/15] Fix and run tests --- .github/workflows/dotnet-release.yml | 9 +-- .github/workflows/dotnet.yml | 73 ++++++++++++------- Castle.Windsor.sln | 6 +- .../Castle.Facilities.AspNet.Mvc.Tests.csproj | 2 +- ...e.Facilities.AspNet.SystemWeb.Tests.csproj | 2 +- ...stle.Facilities.AspNet.WebApi.Tests.csproj | 2 +- .../Castle.Facilities.AspNetCore.Tests.csproj | 2 +- .../Castle.Facilities.AspNetCore.csproj | 14 ++-- ...tle.Facilities.WcfIntegration.Tests.csproj | 2 +- .../Castle.Windsor.Tests.csproj | 9 ++- .../Config/ConfigurationTestCase.cs | 5 +- .../LoggingFacility/BaseTest.cs | 5 +- 12 files changed, 78 insertions(+), 53 deletions(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 3234b47ffc..6d773e1428 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -18,12 +18,9 @@ jobs: run: dotnet restore - name: Build Release run: dotnet build Castle.Windsor.sln -c Release - - name: Castle.Windsor.Tests - run: dotnet test src/Castle.Windsor.Tests - - name: Castle.Windsor.Extensions.DependencyInjection.Tests - run: dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests - - name: Castle.Facilities.AspNetCore.Tests - run: dotnet test src/Castle.Facilities.AspNetCore.Tests + - name: Test on .NET 6.0 + run: dotnet test -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + deploy: needs: build-ubuntu runs-on: ubuntu-latest diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index d373e4b5b9..118bdefe3f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,44 +1,67 @@ name: .NET CI on: - push: - paths-ignore: - - '**.md' - - '.github/**' pull_request: branches: [ master, main ] paths-ignore: - '**.md' - - '.github/**' jobs: build: - + name: Build and test Linux runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup .NET 6.0 - uses: actions/setup-dotnet@v1 + + # Building requires an up-to-date .NET SDK. + - name: Setup dotnet + uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: | + 6.0.x + 7.0.x + + # Restore and build - name: Restore dependencies - run: dotnet restore + run: dotnet restore - name: Build Nuget Versions - run: dotnet build ./tools/Explicit.NuGet.Versions/Explicit.NuGet.Versions.sln + run: dotnet build ./tools/Explicit.NuGet.Versions/Explicit.NuGet.Versions.sln - name: Build Release run: dotnet build Castle.Windsor.sln -c Release - - name: Castle.Windsor.Tests - run: dotnet test src/Castle.Windsor.Tests - - name: Castle.Windsor.Extensions.DependencyInjection.Tests - run: dotnet test src/Castle.Windsor.Extensions.DependencyInjection.Tests - - name: Castle.Facilities.AspNetCore.Tests - run: dotnet test src/Castle.Facilities.AspNetCore.Tests - - name: Castle.Facilities.AspNet.SystemWeb.Tests - run: dotnet test src/Castle.Facilities.AspNet.SystemWeb.Tests - - name: Castle.Facilities.AspNet.Mvc.Tests - run: dotnet test src/Castle.Facilities.AspNet.Mvc.Tests - - name: Castle.Facilities.AspNet.WebApi.Tests - run: dotnet test src/Castle.Facilities.AspNet.WebApi.Tests - - name: Castle.Facilities.WcfIntegration.Tests - run: dotnet test src/Castle.Facilities.WcfIntegration.Tests + + # 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.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + + test-windows: + name: Build and test on Windows + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + # 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" diff --git a/Castle.Windsor.sln b/Castle.Windsor.sln index b2e7f6ee36..f5c2203e36 100644 --- a/Castle.Windsor.sln +++ b/Castle.Windsor.sln @@ -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 @@ -23,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Castle Build", "Castle Buil 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 diff --git a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj index ccb0686472..55ee79c2e6 100644 --- a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj +++ b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj index 76f9f3266d..9b287d5a60 100644 --- a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj +++ b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj index af37968903..5c4bb1721d 100644 --- a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj +++ b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj b/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj index 4efbaf31da..a8077e09a4 100644 --- a/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj +++ b/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj b/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj index 69d652dbda..d9e239c4ef 100644 --- a/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj +++ b/src/Castle.Facilities.AspNetCore/Castle.Facilities.AspNetCore.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -18,12 +18,12 @@ Castle.Facilities.AspNetCore - - - - - - + + + + + + diff --git a/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj b/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj index 11b5401dc0..74829b457c 100644 --- a/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj +++ b/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj index 474f70187f..e508112e88 100644 --- a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj +++ b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj @@ -1,7 +1,7 @@  - net462;netcoreapp3.1;net6.0 + net462;netcoreapp3.1;net6.0 @@ -47,7 +47,8 @@ - + + @@ -67,8 +68,8 @@ - - + + $(DefineConstants);FEATURE_THREADABORT;FEATURE_WPF;FEATURE_CONSOLETRACELISTENER diff --git a/src/Castle.Windsor.Tests/Config/ConfigurationTestCase.cs b/src/Castle.Windsor.Tests/Config/ConfigurationTestCase.cs index e8a6858775..83b613b5c7 100644 --- a/src/Castle.Windsor.Tests/Config/ConfigurationTestCase.cs +++ b/src/Castle.Windsor.Tests/Config/ConfigurationTestCase.cs @@ -15,7 +15,7 @@ namespace Castle.MicroKernel.Tests.Configuration { using System.Collections.Generic; - + using System.IO; using Castle.Core; using Castle.Core.Configuration; using Castle.Core.Resource; @@ -218,7 +218,8 @@ public void ShouldNotThrowCircularDependencyException() [Test] public void Can_properly_populate_array_dependency_from_xml_config_when_registering_by_convention() { - Container.Install(Configuration.FromXmlFile("config\\ComponentWithArrayDependency.config")) + var path = Path.Combine("Config", "ComponentWithArrayDependency.config"); + Container.Install(Configuration.FromXmlFile(path)) .Register(Component.For().ImplementedBy().Named("componentWithArrayDependency")); Container.Register( Classes.FromAssembly(GetCurrentAssembly()).Pick().WithServiceFirstInterface()); diff --git a/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs b/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs index 0fb1a91578..12616e4471 100644 --- a/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs +++ b/src/Castle.Windsor.Tests/LoggingFacility/BaseTest.cs @@ -19,6 +19,7 @@ namespace Castle.Facilities.Logging.Tests using Castle.Services.Logging.Log4netIntegration; using Castle.Services.Logging.NLogIntegration; using Castle.Windsor; + using System.IO; /// /// Summary description for BaseTest. @@ -42,12 +43,12 @@ protected string GetConfigFile() if (typeof(TLoggerFactory) == typeof(Log4netFactory) || typeof(TLoggerFactory) == typeof(ExtendedLog4netFactory)) { - return "LoggingFacility\\log4net.facilities.test.config"; + return Path.Combine("LoggingFacility", "log4net.facilities.test.config"); } if (typeof(TLoggerFactory) == typeof(NLogFactory) || typeof(TLoggerFactory) == typeof(ExtendedNLogFactory)) { - return "LoggingFacility\\NLog.facilities.test.config"; + return Path.Combine("LoggingFacility", "NLog.facilities.test.config"); } return string.Empty; } From ed6c3026c9284e61fc1330106304ab8476a89bf9 Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Fri, 21 Jul 2023 10:39:51 +0200 Subject: [PATCH 13/15] Split workflows for reuse --- .github/workflows/build-test-linux.yml | 33 ++++++++++++++ .github/workflows/build-test-win.yml | 34 +++++++++++++++ .github/workflows/dotnet-release.yml | 42 +++++++++--------- .github/workflows/dotnet.yml | 59 ++------------------------ Castle.Windsor.sln | 2 + 5 files changed, 94 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/build-test-linux.yml create mode 100644 .github/workflows/build-test-win.yml diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml new file mode 100644 index 0000000000..75cb0f9bf8 --- /dev/null +++ b/.github/workflows/build-test-linux.yml @@ -0,0 +1,33 @@ +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.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" \ No newline at end of file diff --git a/.github/workflows/build-test-win.yml b/.github/workflows/build-test-win.yml new file mode 100644 index 0000000000..94391a0b93 --- /dev/null +++ b/.github/workflows/build-test-win.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index 6d773e1428..a801878be5 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -6,38 +6,38 @@ on: - 'v*.*.*' jobs: - build-ubuntu: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup .NET 7.0 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 7.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build Release - run: dotnet build Castle.Windsor.sln -c Release - - name: Test on .NET 6.0 - run: dotnet test -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + 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-ubuntu + needs: [build-lin, build-win] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v3 + + # Building requires an up-to-date .NET SDK. + - name: Setup dotnet + uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + 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 --configuration Release - name: Pack - run: dotnet pack Castle.Windsor.sln -c Release -o ./artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + run: dotnet pack Castle.Windsor.sln -c Release -o artifacts -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} + - name: Push generated Rebus package to GitHub registry - run: dotnet nuget push /home/runner/work/Windsor/Windsor/artifacts/Castle.Windsor.${{ steps.get_version.outputs.VERSION }}.nupkg -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file + run: dotnet nuget push artifacts -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 118bdefe3f..250e6544e6 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -7,61 +7,10 @@ on: - '**.md' jobs: - build: + build-lin: name: Build and test Linux - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - # 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.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" + uses: ./.github/workflows/build-test-linux.yml - test-windows: + build-win: name: Build and test on Windows - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - # 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" + uses: ./.github/workflows/build-test-win.yml diff --git a/Castle.Windsor.sln b/Castle.Windsor.sln index f5c2203e36..d438cb73f5 100644 --- a/Castle.Windsor.sln +++ b/Castle.Windsor.sln @@ -20,6 +20,8 @@ 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 From 456278f109b5778d8fd8e471991db9bbe6191ebe Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Fri, 21 Jul 2023 10:59:50 +0200 Subject: [PATCH 14/15] Run ASP tests as NET6 --- .github/workflows/build-test-linux.yml | 3 ++- .../Castle.Facilities.AspNetCore.Tests.csproj | 6 +++--- src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test-linux.yml b/.github/workflows/build-test-linux.yml index 75cb0f9bf8..37880ad8bf 100644 --- a/.github/workflows/build-test-linux.yml +++ b/.github/workflows/build-test-linux.yml @@ -30,4 +30,5 @@ jobs: - 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.Windsor.Extensions.DependencyInjection.Tests -c Release -f net6.0 --no-build --no-restore -l "console;verbosity=detailed" \ No newline at end of file + 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" diff --git a/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj b/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj index a8077e09a4..db42d80d66 100644 --- a/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj +++ b/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj @@ -1,13 +1,13 @@ - + - netcoreapp3.1 + net6.0 - + diff --git a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj index e508112e88..f0e9932ea1 100644 --- a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj +++ b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj @@ -54,7 +54,7 @@ - + @@ -68,7 +68,7 @@ - + $(DefineConstants);FEATURE_THREADABORT;FEATURE_WPF;FEATURE_CONSOLETRACELISTENER From 48c19e27546c882a442ca4dbf7e3dc844ceb71ec Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Thu, 27 Jul 2023 12:06:13 +0200 Subject: [PATCH 15/15] Push packages to github --- .github/workflows/dotnet-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index a801878be5..1269a95389 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -35,9 +35,9 @@ jobs: 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 --configuration Release + 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 Rebus package to GitHub registry - run: dotnet nuget push artifacts -k ${{secrets.NUGET_SECRET_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols \ No newline at end of file + - 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 \ No newline at end of file