Permalink
Browse files

dotnet core

  • Loading branch information...
1 parent 94c4975 commit 7f268340912e8ff13f71f11c1f260208bdb678bf @rogeralsing committed Mar 30, 2016
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/Wire.sln.iml" filepath="$PROJECT_DIR$/Wire.sln.iml" />
+ </modules>
+ </component>
+</project>
View
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project>
View
Oops, something went wrong.
View
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="RIDER_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+ </content>
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module>
View
@@ -5,7 +5,9 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
+#if false
using System.Runtime.Serialization;
+#endif
using System.Text;
using Wire.ValueSerializers;
using static System.Linq.Expressions.Expression;
@@ -103,7 +105,11 @@ public static void BuildSerializer(Serializer serializer, Type type, ObjectSeria
ValueReader reader = (stream, session) =>
{
//create instance without calling constructor
+#if false
var instance = FormatterServices.GetUninitializedObject(type);
+#else
+ var instance = "";
+#endif
if (preserveObjectReferences)
{
session.TrackDeserializedObject(instance);
@@ -184,14 +190,16 @@ private static FieldInfo[] GetFieldInfosForType(Type type)
var tfields =
current
.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
+#if false
.Where(f => !f.IsDefined(typeof (NonSerializedAttribute)))
+#endif
.Where(f => !f.IsStatic)
.Where(f => f.FieldType != typeof (IntPtr))
.Where(f => f.FieldType != typeof (UIntPtr))
.Where(f => f.Name != "_syncRoot"); //HACK: ignore these
fieldInfos.AddRange(tfields);
- current = current.BaseType;
+ current = current.GetTypeInfo().BaseType;
}
var fields = fieldInfos.OrderBy(f => f.Name).ToArray();
return fields;
@@ -222,7 +230,7 @@ private static FieldInfo[] GetFieldInfosForType(Type type)
var valueExp = Parameter(typeof (object), "value");
// ReSharper disable once PossibleNullReferenceException
- Expression castTartgetExp = field.DeclaringType.IsValueType
+ Expression castTartgetExp = field.DeclaringType.GetTypeInfo().IsValueType
? Unbox(targetExp, type)
: Convert(targetExp, type);
Expression castValueExp = Convert(valueExp, field.FieldType);
@@ -284,7 +292,7 @@ private static ValueWriter GenerateFieldInfoSerializer(Serializer serializer, Fi
else
{
var valueType = field.FieldType;
- if (field.FieldType.IsGenericType && field.FieldType.GetGenericTypeDefinition() == typeof (Nullable<>))
+ if (field.FieldType.GetTypeInfo().IsGenericType && field.FieldType.GetGenericTypeDefinition() == typeof (Nullable<>))
{
var nullableType = field.FieldType.GetGenericArguments()[0];
valueSerializer = serializer.GetSerializerByType(nullableType);
@@ -309,7 +317,7 @@ private static ValueWriter GenerateFieldInfoSerializer(Serializer serializer, Fi
var param = Parameter(typeof (object));
// ReSharper disable once PossibleNullReferenceException
- Expression castParam = field.DeclaringType.IsValueType
+ Expression castParam = field.DeclaringType.GetTypeInfo().IsValueType
? Unbox(param, field.DeclaringType)
: Convert(param, field.DeclaringType);
Expression readField = Field(castParam, field);
View
@@ -30,7 +30,7 @@ public class Serializer
private static readonly Type ByteArrayType = typeof (byte[]);
private static readonly Type TypeType = typeof (Type);
private static readonly Type RuntimeType = Type.GetType("System.RuntimeType");
- private static readonly Assembly CoreAssembly = typeof (int).Assembly;
+ private static readonly Assembly CoreAssembly = typeof (int).GetTypeInfo().Assembly;
private readonly ConcurrentDictionary<Type, ValueSerializer> _deserializers =
new ConcurrentDictionary<Type, ValueSerializer>();
@@ -153,7 +153,7 @@ public ValueSerializer GetSerializerByType(Type type)
// return tmp;
//}
- if (ReferenceEquals(type.Assembly, CoreAssembly))
+ if (ReferenceEquals(type.GetTypeInfo().Assembly, CoreAssembly))
{
if (type == StringType)
return StringSerializer.Instance;
@@ -226,7 +226,7 @@ public ValueSerializer GetSerializerByType(Type type)
public ValueSerializer GetDeserializerByType(Type type)
{
- if (ReferenceEquals(type.Assembly, CoreAssembly))
+ if (ReferenceEquals(type.GetTypeInfo().Assembly, CoreAssembly))
{
if (type == StringType)
return StringSerializer.Instance;
@@ -3,6 +3,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using Wire.ValueSerializers;
namespace Wire.SerializerFactories
@@ -18,7 +19,7 @@ private static bool IsInterface(Type type)
{
return type
.GetInterfaces()
- .Select(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof (IDictionary<,>))
+ .Select(t => t.GetTypeInfo().IsGenericType && t.GetTypeInfo().GetGenericTypeDefinition() == typeof (IDictionary<,>))
.Any(isDict => isDict);
}
@@ -3,6 +3,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using Wire.ValueSerializers;
namespace Wire.SerializerFactories
@@ -34,7 +35,7 @@ public override bool CanDeserialize(Serializer serializer, Type type)
private static Type GetEnumerableType(Type type)
{
return type.GetInterfaces()
- .Where(intType => intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof (IEnumerable<>))
+ .Where(intType => intType.GetTypeInfo().IsGenericType && intType.GetGenericTypeDefinition() == typeof (IEnumerable<>))
.Select(intType => intType.GetGenericArguments()[0])
.FirstOrDefault();
}
@@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using Wire.ValueSerializers;
namespace Wire.SerializerFactories
@@ -21,7 +22,7 @@ public override bool CanDeserialize(Serializer serializer, Type type)
private static Type GetEnumerableType(Type type)
{
return type.GetInterfaces()
- .Where(intType => intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+ .Where(intType => intType.GetTypeInfo().IsGenericType && intType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
.Select(intType => intType.GetGenericArguments()[0])
.FirstOrDefault();
}
@@ -34,7 +35,7 @@ private static Type GetEnumerableType(Type type)
var elementType = GetEnumerableType(type);
var arrType = elementType.MakeArrayType();
- var listModule = type.Assembly.GetType("Microsoft.FSharp.Collections.ListModule");
+ var listModule = type.GetTypeInfo().Assembly.GetType("Microsoft.FSharp.Collections.ListModule");
var ofArray = listModule.GetMethod("OfArray");
var ofArrayConcrete = ofArray.MakeGenericMethod(elementType);
var ofArrayCompiled = CodeGenerator.CompileToDelegate(ofArrayConcrete, arrType);
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
+using System.Reflection;
using Wire.ValueSerializers;
namespace Wire.SerializerFactories
@@ -21,7 +22,7 @@ public override bool CanDeserialize(Serializer serializer, Type type)
public override ValueSerializer BuildSerializer(Serializer serializer, Type type,
ConcurrentDictionary<Type, ValueSerializer> typeMapping)
{
- var surrogate = serializer.Options.Surrogates.FirstOrDefault(s => s.To.IsAssignableFrom(type));
+ var surrogate = serializer.Options.Surrogates.FirstOrDefault(s => s.To.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()));
var objectSerializer = new ObjectSerializer(type);
// ReSharper disable once PossibleNullReferenceException
var fromSurrogateSerializer = new FromSurrogateSerializer(surrogate.FromSurrogate, objectSerializer);
@@ -1,4 +1,5 @@
-using System;
+#if false
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
@@ -66,4 +67,5 @@ public override bool CanDeserialize(Serializer serializer, Type type)
return serializableSerializer;
}
}
-}
+}
+#endif
@@ -33,7 +33,7 @@ public override bool CanDeserialize(Serializer serializer, Type type)
private static Type GetEnumerableType(Type type)
{
return type.GetInterfaces()
- .Where(intType => intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof (IEnumerable<>))
+ .Where(intType => intType.GetTypeInfo().IsGenericType && intType.GetGenericTypeDefinition() == typeof (IEnumerable<>))
.Select(intType => intType.GetGenericArguments()[0])
.FirstOrDefault();
}
@@ -55,9 +55,7 @@ private static Type GetEnumerableType(Type type)
{
// object can be IEnumerable but not ICollection i.e. ImmutableQueue
var e = (IEnumerable) o;
- var list = new ArrayList();
- foreach (var element in e)
- list.Add(element);
+ var list = e.Cast<object>().ToList();//
enumerable = list;
}
@@ -88,7 +86,7 @@ private static Type GetEnumerableType(Type type)
var creatorType =
Type.GetType(
ImmutableCollectionsNamespace + "." + typeName + ", " + ImmutableCollectionsAssembly, true);
- var genericTypes = elementType.IsGenericType
+ var genericTypes = elementType.GetTypeInfo().IsGenericType
? elementType.GetGenericArguments()
: new[] {elementType};
var createRange = creatorType.GetMethods(BindingFlags.Public | BindingFlags.Static)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
+using System.Reflection;
using Wire.ValueSerializers;
namespace Wire.SerializerFactories
@@ -21,7 +22,7 @@ public override bool CanDeserialize(Serializer serializer, Type type)
public override ValueSerializer BuildSerializer(Serializer serializer, Type type,
ConcurrentDictionary<Type, ValueSerializer> typeMapping)
{
- var surrogate = serializer.Options.Surrogates.FirstOrDefault(s => s.From.IsAssignableFrom(type));
+ var surrogate = serializer.Options.Surrogates.FirstOrDefault(s => s.From.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()));
// ReSharper disable once PossibleNullReferenceException
ValueSerializer objectSerializer = new ObjectSerializer(surrogate.To);
var toSurrogateSerializer = new ToSurrogateSerializer(surrogate.ToSurrogate, surrogate.To, objectSerializer);
@@ -19,7 +19,9 @@ public class SerializerOptions
new DefaultDictionarySerializerFactory(),
new DictionarySerializerFactory(),
new ArraySerializerFactory(),
+#if false
new ISerializableSerializerFactory(),
+#endif
new EnumerableSerializerFactory(),
};
View
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
namespace Wire
{
@@ -24,6 +25,7 @@ public static string ToQualifiedAssemblyName(string shortName)
return shortName.Replace(",%core%", CoreAssemblyName);
}
+#if false
public static unsafe bool UnsafeCompare(byte[] a1, byte[] a2)
{
if (a1 == null || a2 == null || a1.Length != a2.Length)
@@ -50,6 +52,12 @@ public static unsafe bool UnsafeCompare(byte[] a1, byte[] a2)
return true;
}
}
+#else
+ public static bool UnsafeCompare(byte[] a1, byte[] a2)
+ {
+ return StructuralComparisons.StructuralEqualityComparer.Equals(a1, a2);
+ }
+#endif
public static bool IsFixedSizeType(Type type)
{
@@ -99,7 +99,7 @@ private static Type GetTypeFromManifestName(Stream stream, DeserializerSession s
return TypeNameLookup.GetOrAdd(bytes, b =>
{
- var shortName = Encoding.UTF8.GetString(b);
+ var shortName = Encoding.UTF8.GetString(b,0,b.Length);
var typename = Utils.ToQualifiedAssemblyName(shortName);
return Type.GetType(typename, true);
});
View
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25029.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Wire", "Wire\Wire.xproj", "{2F1B0D6F-26B2-4ECC-801C-3506C1B86189}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2F1B0D6F-26B2-4ECC-801C-3506C1B86189}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F1B0D6F-26B2-4ECC-801C-3506C1B86189}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F1B0D6F-26B2-4ECC-801C-3506C1B86189}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F1B0D6F-26B2-4ECC-801C-3506C1B86189}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
@@ -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)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>2f1b0d6f-26b2-4ecc-801c-3506c1b86189</ProjectGuid>
+ <RootNamespace>Wire</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)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
+</Project>
View
@@ -0,0 +1,22 @@
+{
+ "version": "1.0.0-*",
+ "description": "Wire Class Library",
+ "authors": [ "ralsing" ],
+ "tags": [ "" ],
+ "projectUrl": "",
+ "licenseUrl": "",
+
+ "frameworks": {
+ "net451": { },
+ "dotnet5.4": {
+ "dependencies": {
+ "Microsoft.CSharp": "4.0.1-beta-23516",
+ "System.Collections": "4.0.11-beta-23516",
+ "System.Linq": "4.0.1-beta-23516",
+ "System.Runtime": "4.0.21-beta-23516",
+ "System.Threading": "4.0.11-beta-23516",
+ "System.Collections.Concurrent": "4.0.12-rc2-23811",
+ }
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 7f26834

Please sign in to comment.