Skip to content

Commit

Permalink
Add FV project for K runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremySkinner committed Jan 27, 2015
1 parent a7a98af commit f0b19cf
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -13,4 +13,5 @@ TestResult.xml
*.orig
.hg/
.hgignore
packages/
packages/
*.sln.ide/
10 changes: 8 additions & 2 deletions FluentValidation.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.22310.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3906F280-A567-4AD7-A0EF-7253E95E7852}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -49,6 +49,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentValidation.Tests.WebA
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentValidation.Portable40", "src\FluentValidation.Portable40\FluentValidation.Portable40.csproj", "{4496CA2C-E818-4758-84DA-EAF9BFE48ADB}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FluentValidation.K", "src\FluentValidation.K\FluentValidation.K.kproj", "{33895E3B-410F-4465-A1C4-8FABB6C0AA2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -87,6 +89,10 @@ Global
{4496CA2C-E818-4758-84DA-EAF9BFE48ADB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4496CA2C-E818-4758-84DA-EAF9BFE48ADB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4496CA2C-E818-4758-84DA-EAF9BFE48ADB}.Release|Any CPU.Build.0 = Release|Any CPU
{33895E3B-410F-4465-A1C4-8FABB6C0AA2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33895E3B-410F-4465-A1C4-8FABB6C0AA2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33895E3B-410F-4465-A1C4-8FABB6C0AA2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33895E3B-410F-4465-A1C4-8FABB6C0AA2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 3 additions & 0 deletions global.json
@@ -0,0 +1,3 @@
{
"sources": ["src"]
}
20 changes: 20 additions & 0 deletions src/FluentValidation.K/FluentValidation.K.kproj
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>33895e3b-410f-4465-a1c4-8fabb6c0aa2a</ProjectGuid>
<RootNamespace>FluentValidation.K</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
28 changes: 28 additions & 0 deletions src/FluentValidation.K/project.json
@@ -0,0 +1,28 @@
{
"code": "../FluentValidation/**/*.cs",
"exclude": "../FluentValidation/BackwardsCompatibility.cs",
//"exclude": "../FluentValidation/Resources;../FluentValidation/taskhelper/**;../FluentValidation/BackwardsCompatibility.cs;../FluentValidation/Validators/NestedValidatorAdaptor.cs",
"dependencies": {
"System.Linq": "4.0.0.0-beta-22231",
"System.Reflection": "4.0.10.0-beta-22231",
"System.Reflection.Extensions": "4.0.0.0-beta-22231",
"System.Runtime.Extensions": "4.0.10.0-beta-22231",
"System.Reflection.TypeExtensions": "4.0.0.0-beta-22231",
"System.ComponentModel": "4.0.0-beta-22231",
"System.Resources.ResourceManager": "4.0.0-beta-22231",
"System.Text.RegularExpressions": "4.0.10-beta-22231",
"System.Threading": "4.0.0-beta-22231",
"System.Linq.Expressions": "4.0.0-beta-22231",
"System.Diagnostics.Contracts": "4.0.0-beta-22231",
"System.Diagnostics.Debug": "4.0.10-beta-22231",
"System.Diagnostics.Tools": "4.0.0-beta-22231"
},

"frameworks": {
"aspnetcore50": {
}
},
"compilationOptions": {
"define": [ "CoreCLR" ]
}
}
5 changes: 3 additions & 2 deletions src/FluentValidation/AssemblyScanner.cs
Expand Up @@ -22,6 +22,7 @@ namespace FluentValidation {
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Internal;

/// <summary>
/// Class that can be used to find all the validators from a collection of types.
Expand All @@ -47,15 +48,15 @@ public class AssemblyScanner : IEnumerable<AssemblyScanner.AssemblyScanResult> {
/// Finds all the validators in the assembly containing the specified type.
/// </summary>
public static AssemblyScanner FindValidatorsInAssemblyContaining<T>() {
return FindValidatorsInAssembly(typeof(T).Assembly);
return FindValidatorsInAssembly(typeof(T).GetAssembly());
}

private IEnumerable<AssemblyScanResult> Execute() {
var openGenericType = typeof(IValidator<>);

var query = from type in types
let interfaces = type.GetInterfaces()
let genericInterfaces = interfaces.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == openGenericType)
let genericInterfaces = interfaces.Where(i => i.IsGenericType() && i.GetGenericTypeDefinition() == openGenericType)
let matchingInterface = genericInterfaces.FirstOrDefault()
where matchingInterface != null
select new AssemblyScanResult(matchingInterface, type);
Expand Down
25 changes: 17 additions & 8 deletions src/FluentValidation/Internal/Compatibility.cs
Expand Up @@ -26,23 +26,23 @@ namespace FluentValidation.Internal {
/// </summary>
internal static class Compatibility {
public static PropertyInfo GetPublicStaticProperty(this Type type, string propertyName) {
#if PORTABLE
#if PORTABLE || CoreCLR
return type.GetRuntimeProperty(propertyName);
#else
return type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Static);
#endif
}

public static MethodInfo GetPublicInstanceMethod(this Type type, string name) {
#if PORTABLE
#if PORTABLE || CoreCLR
return type.GetRuntimeMethod(name, null);
#else
return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public);
#endif
}

public static PropertyInfo GetPublicInstanceProperty(this Type type, string name) {
#if PORTABLE
#if PORTABLE || CoreCLR
return type.GetRuntimeProperty(name);
#else
return type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public);
Expand All @@ -51,7 +51,7 @@ internal static class Compatibility {

public static Func<string> CreateGetter(this PropertyInfo property) {
Func<string> accessor;
#if PORTABLE
#if PORTABLE || CoreCLR
accessor = (Func<string>)property.GetMethod.CreateDelegate(typeof(Func<string>), property.GetMethod);
#else
accessor = (Func<string>)Delegate.CreateDelegate(typeof(Func<string>), property.GetGetMethod());
Expand All @@ -60,15 +60,15 @@ internal static class Compatibility {
}

public static bool CanAssignTo(this Type type, Type other) {
#if PORTABLE
#if PORTABLE || CoreCLR
return other.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo());
#else
return other.IsAssignableFrom(type);
#endif
}

public static ValidatorAttribute GetValidatorAttribute(this Type type) {
#if PORTABLE
#if PORTABLE || CoreCLR
var attribute = (ValidatorAttribute)type.GetTypeInfo().GetCustomAttribute<ValidatorAttribute>(true);
#else
var attribute = (ValidatorAttribute)Attribute.GetCustomAttribute(type, typeof(ValidatorAttribute));
Expand All @@ -77,19 +77,28 @@ internal static class Compatibility {
}

public static Assembly GetAssembly(this Type type) {
#if PORTABLE
#if PORTABLE || CoreCLR
return typeof(Messages).GetTypeInfo().Assembly;
#else
return typeof(Messages).Assembly;
#endif
}

public static MethodInfo GetDeclaredMethod(this Type type, string name) {
#if PORTABLE
#if PORTABLE || CoreCLR
return type.GetTypeInfo().GetDeclaredMethod(name);
#else
return type.GetMethod(name, new Type[0]);
#endif
}

public static bool IsGenericType(this Type type)
{
#if PORTABLE || CoreCLR
return type.GetTypeInfo().IsGenericType;
#else
return type.IsGenericType;
#endif
}
}
}
2 changes: 1 addition & 1 deletion src/FluentValidation/Results/ValidationFailure.cs
Expand Up @@ -20,7 +20,7 @@ namespace FluentValidation.Results {
using System;
using System.Collections.Generic;

#if !SILVERLIGHT && !PORTABLE && !PORTABLE40
#if !SILVERLIGHT && !PORTABLE && !PORTABLE40 && !CoreCLR
[Serializable]
#endif
public class ValidationFailure {
Expand Down
2 changes: 1 addition & 1 deletion src/FluentValidation/Results/ValidationResult.cs
Expand Up @@ -21,7 +21,7 @@ namespace FluentValidation.Results {
using System.Collections.Generic;
using System.Linq;

#if !SILVERLIGHT && !PORTABLE && !PORTABLE40
#if !SILVERLIGHT && !PORTABLE && !PORTABLE40 && !CoreCLR
[Serializable]
#endif
public class ValidationResult {
Expand Down
2 changes: 1 addition & 1 deletion src/FluentValidation/TaskHelpers/TaskHelpersExtensions.cs
Expand Up @@ -466,7 +466,7 @@ private static Action<Task> GetRethrowWithNoStackLossDelegate()
else
{
Func<Exception, Exception> prepForRemoting = null;
#if !PORTABLE && !PORTABLE40
#if !PORTABLE && !PORTABLE40 && !CoreCLR
try
{
if (AppDomain.CurrentDomain.IsFullyTrusted)
Expand Down

0 comments on commit f0b19cf

Please sign in to comment.