Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core support for Castle.Core #92

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ _ReSharper*

*.orig
*~
artifacts
*.lock.json
packages
.vs
*.nuget.targets
33 changes: 33 additions & 0 deletions Castle.Core-NetCore.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.Core.NetCore", "src\Castle.Core.NetCore\Castle.Core.NetCore.csproj", "{9C846611-F9BF-455D-A92F-5092657DB944}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Castle.Core.NetCore.UnitTests", "src\Castle.Core.NetCore.UnitTests\src\Castle.Core.NetCore.UnitTests.xproj", "{24BB4B22-103D-48BB-BD5C-905B9B5EA149}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EFFD4CEA-0C67-4B36-B2FE-CDADBACE1C5C}"
ProjectSection(SolutionItems) = preProject
src\Castle.Core.NetCore.UnitTests\global.json = src\Castle.Core.NetCore.UnitTests\global.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C846611-F9BF-455D-A92F-5092657DB944}.Debug|Any CPU.ActiveCfg = NetCore-Debug|Any CPU
{9C846611-F9BF-455D-A92F-5092657DB944}.Debug|Any CPU.Build.0 = NetCore-Debug|Any CPU
{9C846611-F9BF-455D-A92F-5092657DB944}.Release|Any CPU.ActiveCfg = NetCore-Release|Any CPU
{9C846611-F9BF-455D-A92F-5092657DB944}.Release|Any CPU.Build.0 = NetCore-Release|Any CPU
{24BB4B22-103D-48BB-BD5C-905B9B5EA149}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24BB4B22-103D-48BB-BD5C-905B9B5EA149}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24BB4B22-103D-48BB-BD5C-905B9B5EA149}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24BB4B22-103D-48BB-BD5C-905B9B5EA149}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
53 changes: 1 addition & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1 @@
# Castle Core

<img align="right" src="docs/images/castle-logo.png">

Castle Core provides common Castle Project abstractions including logging services. It also features **Castle DynamicProxy** a lightweight runtime proxy generator, and **Castle DictionaryAdapter**.

See the [documentation](docs/README.md).

## Releases

See the [Releases](https://github.com/castleproject/Core/releases).

## License

Castle Core is &copy; 2004-2015 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.

## Building

### .NET Framework and Silverlight

```
msbuild /p:Configuration=NET45-Release /t:RunAllTests buildscripts/Build.proj
msbuild /p:Configuration=NET40-Release /t:RunAllTests buildscripts/Build.proj
msbuild /p:Configuration=NET35-Release /t:RunAllTests buildscripts/Build.proj
msbuild /p:Configuration=SL50-Release /t:RunAllTests buildscripts/Build.proj
msbuild /p:Configuration=SL40-Release /t:RunAllTests buildscripts/Build.proj
```

### Mono

Castle Core supports Mono 4.0.2+, previous 4.x releases have serious runtime bugs that cause runtime crashes. Mono 3.x releases used to work well, but are not supported.

```
xbuild /p:Configuration=NET45-Release /t:RunAllTests buildscripts/Build.proj
```

### Conditional Compilation Symbols

The following conditional compilation symbols (vertical) are currently defined for each of the build configurations (horizontal):

Symbol | NET35 | NET40 | NET45 | SL40 | SL50
------------------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------------
`FEATURE_LEGACY_REFLECTION_API` | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :white_check_mark: | :white_check_mark:
`FEATURE_SERIALIZATION` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
`DOTNET35` | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign:
`DOTNET40` | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
`DOTNET45` | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
`SILVERLIGHT` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark:
`SL4` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign:
`SL5` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark:

The `__MonoCS__` symbol is used only in unit tests when compiled on Mono to work around Mono defects and non-Windows differences, however we are trying to move away from platform specific symbols as much as possible.
# Castle Core<img align="right" src="docs/images/castle-logo.png">Castle Core provides common Castle Project abstractions including logging services. It also features **Castle DynamicProxy** a lightweight runtime proxy generator, and **Castle DictionaryAdapter**.See the [documentation](docs/README.md).## ReleasesSee the [Releases](https://github.com/castleproject/Core/releases).## LicenseCastle Core is &copy; 2004-2015 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.## Building### .NET Framework and Silverlight```msbuild /p:Configuration=NET45-Release /t:RunAllTests buildscripts/Build.projmsbuild /p:Configuration=NET40-Release /t:RunAllTests buildscripts/Build.projmsbuild /p:Configuration=NET35-Release /t:RunAllTests buildscripts/Build.projmsbuild /p:Configuration=SL50-Release /t:RunAllTests buildscripts/Build.projmsbuild /p:Configuration=SL40-Release /t:RunAllTests buildscripts/Build.proj```### MonoCastle Core supports Mono 4.0.2+, previous 4.x releases have serious runtime bugs that cause runtime crashes. Mono 3.x releases used to work well, but are not supported.```xbuild /p:Configuration=NET45-Release /t:RunAllTests buildscripts/Build.proj```### .NET Core Castle Core supports .NET Core 5.0 in an experimental state currently. ```msbuild /p:Configuration=NetCore-Release src\Castle.Core.NetCore\Castle.Core.NetCore.csproj```### Conditional Compilation SymbolsThe following conditional compilation symbols (vertical) are currently defined for each of the build configurations (horizontal):Symbol | NET35 | NET40 | NET45 | SL40 | SL50------------------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------------`FEATURE_LEGACY_REFLECTION_API` | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :white_check_mark: | :white_check_mark:`FEATURE_SERIALIZATION` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:`DOTNET35` | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign:`DOTNET40` | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:`DOTNET45` | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign:`SILVERLIGHT` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark:`SL4` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign:`SL5` | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark:The `__MonoCS__` symbol is used only in unit tests when compiled on Mono to work around Mono defects and non-Windows differences, however we are trying to move away from platform specific symbols as much as possible.
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ limitations under the License.

<Target Name="CheckRequiredProperties">
<Error Condition="'$(ProjectName)' == ''" Text="The ProjectName property has not been set, please set it in Settings.proj." />
<Error Text="The tools version &quot;$(MSBuildToolsVersion)&quot; is not supported, MSBuild 4.0 or newer is required to build." Condition="'$(MSBuildToolsVersion)' != '4.0'" />
<Error Text="The tools version &quot;$(MSBuildToolsVersion)&quot; is not supported, MSBuild 4.0 or newer is required to build." Condition="$(MSBuildToolsVersion) &lt; 4.0" />

<Error Condition="'$(Project_Major)' == ''" Text="The Project_Major property has not been set, please set it in Settings.proj." />
<Error Condition="'$(Project_Minor)' == ''" Text="The Project_Minor property has not been set, please set it in Settings.proj." />
Expand Down
38 changes: 36 additions & 2 deletions buildscripts/Castle.Core.nuspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Castle.Core</id>
Expand All @@ -13,6 +13,38 @@
<summary>Castle Project Core, including DynamicProxy, Logging Abstractions and DictionaryAdapter</summary>
<copyright>Copyright 2004-$CurrentYear$ Castle Project - http://www.castleproject.org/</copyright>
<tags>castle dynamicproxy dynamic proxy dynamicproxy2 dictionaryadapter emailsender</tags>
<dependencies>
<group targetFramework="dotnet">
<dependency id="System.AppContext" version="4.0.0" />
<dependency id="System.Collections" version="4.0.10" />
<dependency id="System.Collections.Specialized" version="4.0.0" />
<dependency id="System.ComponentModel" version="4.0.0" />
<dependency id="System.ComponentModel.TypeConverter" version="4.0.0" />
<dependency id="System.Console" version="4.0.0-beta-23409" />
<dependency id="System.Diagnostics.Debug" version="4.0.10" />
<dependency id="System.Diagnostics.TraceSource" version="4.0.0-beta-23409" />
<dependency id="System.Dynamic.Runtime" version="4.0.10" />
<dependency id="System.Globalization" version="4.0.10" />
<dependency id="System.IO" version="4.0.10" />
<dependency id="System.IO.FileSystem" version="4.0.0" />
<dependency id="System.IO.FileSystem.Primitives" version="4.0.0" />
<dependency id="System.Linq" version="4.0.0" />
<dependency id="System.ObjectModel" version="4.0.10" />
<dependency id="System.Reflection" version="4.0.10" />
<dependency id="System.Reflection.Emit" version="4.0.0" />
<dependency id="System.Reflection.Emit.ILGeneration" version="4.0.0" />
<dependency id="System.Reflection.Extensions" version="4.0.0" />
<dependency id="System.Reflection.Primitives" version="4.0.0" />
<dependency id="System.Reflection.TypeExtensions" version="4.0.0" />
<dependency id="System.Resources.ResourceManager" version="4.0.0" />
<dependency id="System.Runtime" version="4.0.20" />
<dependency id="System.Runtime.Extensions" version="4.0.10" />
<dependency id="System.Text.Encoding" version="4.0.10" />
<dependency id="System.Threading" version="4.0.10" />
<dependency id="System.Xml.ReaderWriter" version="4.0.10" />
<dependency id="System.Xml.XmlDocument" version="4.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="BreakingChanges.txt" />
Expand All @@ -33,8 +65,10 @@
<file src="build/SL5/SL5-Release/pkg/bin/Castle.Core.dll" target="lib/sl5" />
<file src="build/SL5/SL5-Release/pkg/bin/Castle.Core.pdb" target="lib/sl5" />
<file src="build/SL5/SL5-Release/pkg/bin/Castle.Core.xml" target="lib/sl5" />
<file src="build/NetCore/NetCore-Release/pkg/bin/Castle.Core.dll" target="lib/dotnet" />
<file src="build/NetCore/NetCore-Release/pkg/bin/Castle.Core.pdb" target="lib/dotnet" />
<file src="buildscripts/ASL - Apache Software Foundation License.txt" />
<file src="buildscripts/readme.txt" />
<file src="src/Castle.Core/**/*.cs" />
</files>
</package>
</package>
10 changes: 10 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"projects": [
"wrap"
],
"sdk": {
"version": "1.0.0-beta5",
"runtime": "coreclr",
"architecture": "x86"
}
}
11 changes: 11 additions & 0 deletions src/Castle.Core.NetCore.UnitTests/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"projects": [
"src",
"wrapper"
],
"sdk": {
"version": "1.0.0-beta8",
"runtime": "coreclr",
"architecture": "x86"
}
}
91 changes: 91 additions & 0 deletions src/Castle.Core.NetCore.UnitTests/src/AccessLevelTestCase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2004-2010 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.DynamicProxy.Tests
{
using Castle.DynamicProxy.Tests.Classes;
using Castle.DynamicProxy.Tests.Interceptors;

using System.Collections.Generic;

using Xunit;

using System.Reflection;

public class AccessLevelTestCase : BasePEVerifyTestCase
{
[Fact]
public void ProtectedConstructor()
{
NonPublicConstructorClass proxy =
generator.CreateClassProxy(
typeof(NonPublicConstructorClass), new StandardInterceptor())
as NonPublicConstructorClass;

Assert.NotNull(proxy);

proxy.DoSomething();
}

[Fact]
public void ProtectedInternalConstructor()
{
ProtectedInternalConstructorClass proxy =
generator.CreateClassProxy(
typeof(ProtectedInternalConstructorClass), new StandardInterceptor())
as ProtectedInternalConstructorClass;

Assert.NotNull(proxy);

proxy.DoSomething();
}

[Fact]
public void ProtectedMethods()
{
LogInvocationInterceptor logger = new LogInvocationInterceptor();

NonPublicMethodsClass proxy = (NonPublicMethodsClass)
generator.CreateClassProxy(typeof(NonPublicMethodsClass), logger);

proxy.DoSomething();
Assert.Equal(2, logger.Invocations.Count);
Assert.Equal("DoSomething", logger.Invocations[0]);
Assert.Equal("DoOtherThing", logger.Invocations[1]);
}

[Fact]
public void InternalConstructorIsNotReplicated()
{
object proxy = generator.CreateClassProxy(typeof(Dictionary<int, object>), new StandardInterceptor());
Assert.Null(proxy.GetType().GetConstructor(new[] { typeof(IInterceptor[]), typeof(bool) }));
}

internal class InternalClass
{
internal InternalClass()
{
}
}

#if !MONO && !SILVERLIGHT && !NETCORE
[Fact]
public void InternalConstructorIsReplicatedWhenInternalsVisibleTo()
{
object proxy = generator.CreateClassProxy(typeof(InternalClass), new StandardInterceptor());
Assert.NotNull(proxy.GetType().GetConstructor(new[] { typeof(IInterceptor[]) }));
}
#endif
}
}
Loading