Skip to content

Commit

Permalink
Merge branch 'master' into remove-obsolete-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonorossi committed Dec 1, 2022
2 parents 7bf729f + f64367f commit 0e494b3
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 75 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ 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)

- Restrict `Castle.Core` dependency to 4.4.1+ and less than 5.x to prevent NuGet using 5.x which has breaking changes (@Jevonius, #610)

## 5.1.1 (2020-12-08)

- Upgrade minimum Castle.Core version to 4.4.1 (@generik0, #576)
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Symbol | .NET 4.6.2 | .NET Standard / 6
`FEATURE_APPDOMAIN` | :white_check_mark: | :no_entry_sign:
`FEATURE_ASSEMBLIES` | :white_check_mark: | :no_entry_sign:
`FEATURE_GAC` | :white_check_mark: | :no_entry_sign:
`FEATURE_ISUPPORTINITIALIZE` | :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:
Expand All @@ -44,7 +43,6 @@ Symbol | .NET 4.6.2 | .NET Standard / 6
* `FEATURE_APPDOMAIN` - enables support for features that make use of an AppDomain in the host.
* `FEATURE_ASSEMBLIES` - uses `AssemblyName.GetAssemblyName()` and `Assembly.LoadFile()`.
* `FEATURE_GAC` - enables support for obtaining assemblies using an assembly's long form name.
* `FEATURE_ISUPPORTINITIALIZE` - enables support for features that make use of `System.ComponentModel.ISupportInitialize`.
* `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 All @@ -57,5 +55,3 @@ The following conditional compilation symbols are defined for tests only under .
* `FEATURE_CONSOLETRACELISTENER` - enables code that requires `System.Diagnostics.ConsoleTraceListener`.
* `FEATURE_THREADABORT` - enables code that uses `Thread.Abort()`.
* `FEATURE_WPF` - enables code that uses `PresentationCore.dll`.
* `NUNIT_SETCULTUREATTRIBUTE` - uses `NUnit.Framework.SetCultureAttribute`.
* `NUNIT_TIMEOUTATTRIBUTE` - uses `NUnit.Framework.TimeoutAttribute`.
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_GAC;FEATURE_ISUPPORTINITIALIZE;FEATURE_REMOTING;FEATURE_SECURITY_PERMISSIONS;FEATURE_SYSTEM_CONFIGURATION;FEATURE_SERIALIZATION;FEATURE_URIMEMBERS;FEATURE_APPDOMAIN;FEATURE_CODEDOM;FEATURE_ASSEMBLIES</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_PERFCOUNTERS;FEATURE_GAC;FEATURE_REMOTING;FEATURE_SECURITY_PERMISSIONS;FEATURE_SYSTEM_CONFIGURATION;FEATURE_SERIALIZATION;FEATURE_URIMEMBERS;FEATURE_APPDOMAIN;FEATURE_CODEDOM;FEATURE_ASSEMBLIES</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net462'">
<DefineConstants>$(DefineConstants);NUNIT_SETCULTUREATTRIBUTE;NUNIT_TIMEOUTATTRIBUTE;FEATURE_THREADABORT;FEATURE_WPF;FEATURE_CONSOLETRACELISTENER</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_THREADABORT;FEATURE_WPF;FEATURE_CONSOLETRACELISTENER</DefineConstants>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,48 +12,36 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if FEATURE_ISUPPORTINITIALIZE
namespace CastleTests.Components
{
using System;
using System.ComponentModel;

public class SimpleServiceSupportInitialize : ISimpleService, ISupportInitialize
{
private bool initBegun;
private bool initEnded;

public bool InitBegun
{
get { return initBegun; }
}

public bool InitEnded
{
get { return initEnded; }
}
public bool InitBegun { get; private set; }
public bool InitEnded { get; private set; }

public void Operation()
{
}

public void BeginInit()
{
if (initEnded)
if (InitEnded)
{
throw new InvalidOperationException("Can't Begin init after it ended");
}
initBegun = true;
InitBegun = true;
}

public void EndInit()
{
if (initBegun == false)
if (InitBegun == false)
{
throw new InvalidOperationException("Can't End init before it begins");
}
initEnded = true;
InitEnded = true;
}
}
}
#endif
26 changes: 7 additions & 19 deletions src/Castle.Windsor.Tests/Components/SupportInitializeComponent.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if FEATURE_ISUPPORTINITIALIZE
namespace CastleTests.Components
{
using System;
Expand All @@ -23,36 +22,25 @@ namespace CastleTests.Components
[Transient]
public class SupportInitializeComponent : ISupportInitialize
{
private bool initBegun;
private bool initEnded;

public bool InitBegun
{
get { return initBegun; }
}

public bool InitEnded
{
get { return initEnded; }
}
public bool InitBegun { get; private set; }
public bool InitEnded { get; private set; }

public void BeginInit()
{
if (initEnded)
if (InitEnded)
{
throw new InvalidOperationException("Can't Begin init after it ended");
}
initBegun = true;
InitBegun = true;
}

public void EndInit()
{
if (initBegun == false)
if (InitBegun == false)
{
throw new InvalidOperationException("Can't End init before it begins");
}
initEnded = true;
InitEnded = true;
}
}
}
#endif
9 changes: 3 additions & 6 deletions src/Castle.Windsor.Tests/DefaultConversionManagerTestCase.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -29,20 +29,17 @@ public class DefaultConversionManagerTestCase
{
private readonly DefaultConversionManager converter = new DefaultConversionManager();

#if NUNIT_SETCULTUREATTRIBUTE
// currently not supported by SL
[Test]
[SetCulture("pl-PL")]
[Bug("IOC-314")]
public void Converting_numbers_uses_oridinal_culture()
public void Converting_numbers_uses_ordinal_culture()
{
Assert.AreEqual(",", Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);

var result = converter.PerformConversion<Decimal>("123.456");
var result = converter.PerformConversion<decimal>("123.456");

Assert.AreEqual(123.456m, result);
}
#endif

[Test]
public void PerformConversionInt()
Expand Down
4 changes: 1 addition & 3 deletions src/Castle.Windsor.Tests/LazyLoadingTestCase.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -63,7 +63,6 @@ public void Component_loaded_lazily_can_have_lazy_dependencies()
Container.Resolve<B>();
}

#if NUNIT_TIMEOUTATTRIBUTE
[Test]
[Timeout(2000)]
public void Loaders_are_thread_safe()
Expand Down Expand Up @@ -98,7 +97,6 @@ public void Loaders_are_thread_safe()
Assert.IsNull(exception);
Assert.AreEqual(0, count[0]);
}
#endif

[Test]
public void Loaders_only_triggered_when_resolving()
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if FEATURE_ISUPPORTINITIALIZE
namespace Castle.Windsor.Tests.Lifecycle
{
using Castle.MicroKernel.Registration;
Expand Down Expand Up @@ -76,4 +75,3 @@ public void SupportsInitialize_components_get_initialized_when_resolved()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if FEATURE_ISUPPORTINITIALIZE
namespace Castle.MicroKernel.LifecycleConcerns
{
using System;
Expand All @@ -26,27 +25,19 @@ namespace Castle.MicroKernel.LifecycleConcerns
[Serializable]
public class SupportInitializeConcern : ICommissionConcern
{
private static readonly SupportInitializeConcern instance = new SupportInitializeConcern();

protected SupportInitializeConcern()
{
}

public void Apply(ComponentModel model, object component)
{
var supportInitialize = component as ISupportInitialize;
if (supportInitialize == null)
if (component is ISupportInitialize supportInitialize)
{
return;
supportInitialize.BeginInit();
supportInitialize.EndInit();
}
supportInitialize.BeginInit();
supportInitialize.EndInit();
}

public static SupportInitializeConcern Instance
{
get { return instance; }
}
public static SupportInitializeConcern Instance { get; } = new SupportInitializeConcern();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -66,7 +66,6 @@ private void ProcessLateBoundModel(ComponentModel model)
commission.AddConcern<IInitializable>(InitializationConcern.Instance);
}

#if FEATURE_ISUPPORTINITIALIZE
if (model.Services.Any(s => s.Is<ISupportInitialize>()))
{
model.Lifecycle.Add(SupportInitializeConcern.Instance);
Expand All @@ -75,7 +74,6 @@ private void ProcessLateBoundModel(ComponentModel model)
{
commission.AddConcern<ISupportInitialize>(SupportInitializeConcern.Instance);
}
#endif

if (commission.HasConcerns)
{
Expand All @@ -101,12 +99,10 @@ private void ProcessModel(ComponentModel model)
model.Lifecycle.Add(InitializationConcern.Instance);
}

#if FEATURE_ISUPPORTINITIALIZE
if (model.Implementation.Is<ISupportInitialize>())
{
model.Lifecycle.Add(SupportInitializeConcern.Instance);
}
#endif

if (model.Implementation.Is<IDisposable>())
{
Expand Down

0 comments on commit 0e494b3

Please sign in to comment.