Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

Commit

Permalink
Added NET 3.5 version of FatturaElettronica.Core
Browse files Browse the repository at this point in the history
  • Loading branch information
workgroupengineering committed Nov 13, 2018
1 parent b92c41a commit 6576543
Show file tree
Hide file tree
Showing 15 changed files with 436 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/Core(3.5)/Compatibily/CompilerServices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
public sealed class CallerMemberNameAttribute : Attribute
{
public CallerMemberNameAttribute()
{
}
}

[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
public sealed class CallerLineNumberAttribute : Attribute
{
public CallerLineNumberAttribute()
{
}
}
}
42 changes: 42 additions & 0 deletions src/Core(3.5)/Compatibily/Reflection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;

namespace System.Reflection
{

static class ReflectionExtensions
{
public static TypeInfo GetTypeInfo(this Type source)
{
return new TypeInfo(source);
}

readonly static object[] EmptyArray = new object[0];

public static PropertyInfo[] GetRuntimeProperties(this Type type)
{
return type.GetProperties();
}

public static IEnumerable<T> GetCustomAttributes<T>(this MemberInfo member, bool inherit = false)
where T : Attribute
{
return (member.GetCustomAttributes(typeof(T), false) ?? EmptyArray)
.OfType<T>();
}

public static T GetCustomAttribute<T>(this MemberInfo member, bool inherit = false)
where T : Attribute
{
return (member.GetCustomAttributes(typeof(T), false) ?? EmptyArray).OfType<T>().Single();
}

public static IEnumerable<MethodInfo> GetRuntimeMethods(this Type type)
{
return type.GetMethods();
}
}

}
107 changes: 107 additions & 0 deletions src/Core(3.5)/Compatibily/TypeInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;

namespace System
{
public class TypeInfo : Type
{
readonly Type type;
readonly static MethodInfo MethodGetAttributeFlagsImpl =
typeof(Type).GetMethod(nameof(GetAttributeFlagsImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodGetConstructorImpl =
typeof(Type).GetMethod(nameof(GetConstructorImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodGetMethodImpl =
typeof(Type).GetMethod(nameof(GetMethodImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodGetPropertyImpl =
typeof(Type).GetMethod(nameof(GetPropertyImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodHasElementTypeImpl =
typeof(Type).GetMethod(nameof(HasElementTypeImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodIsArrayImpl =
typeof(Type).GetMethod(nameof(IsArrayImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodIsByRefImpl =
typeof(Type).GetMethod(nameof(IsByRefImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodIsCOMObjectImpl =
typeof(Type).GetMethod(nameof(IsCOMObjectImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodIsPointerImpl =
typeof(Type).GetMethod(nameof(IsPointerImpl), BindingFlags.Instance | BindingFlags.NonPublic);
readonly static MethodInfo MethodIsPrimitiveImpl =
typeof(Type).GetMethod(nameof(IsPrimitiveImpl), BindingFlags.Instance | BindingFlags.NonPublic);

internal TypeInfo(Type type) => this.type = type;

public override Guid GUID => type.GUID;

public override Module Module => type.Module;

public override Assembly Assembly => type.Assembly;

public override string FullName => type.FullName;

public override string Namespace => type.Namespace;

public override string AssemblyQualifiedName => type.AssemblyQualifiedName;

public override Type BaseType => type.BaseType;

public override Type UnderlyingSystemType => type.UnderlyingSystemType;

public override string Name => type.Name;

public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) => type.GetConstructors(bindingAttr);

public override object[] GetCustomAttributes(bool inherit) => type.GetCustomAttributes(inherit);

public override object[] GetCustomAttributes(Type attributeType, bool inherit) => type.GetCustomAttributes(attributeType, inherit);

public override Type GetElementType() => type.GetElementType();

public override EventInfo GetEvent(string name, BindingFlags bindingAttr) => type.GetEvent(name, bindingAttr);

public override EventInfo[] GetEvents(BindingFlags bindingAttr) => type.GetEvents(bindingAttr);

public override FieldInfo GetField(string name, BindingFlags bindingAttr) => GetField(name, bindingAttr);

public override FieldInfo[] GetFields(BindingFlags bindingAttr) => GetFields(bindingAttr);

public override Type GetInterface(string name, bool ignoreCase) => type.GetInterface(name, ignoreCase);

public override Type[] GetInterfaces() => type.GetInterfaces();

public override MemberInfo[] GetMembers(BindingFlags bindingAttr) => type.GetMembers(bindingAttr);

public override MethodInfo[] GetMethods(BindingFlags bindingAttr) => type.GetMethods(bindingAttr);

public override Type GetNestedType(string name, BindingFlags bindingAttr) => type.GetNestedType(name, bindingAttr);

public override Type[] GetNestedTypes(BindingFlags bindingAttr) => type.GetNestedTypes(bindingAttr);

public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => GetProperties(bindingAttr);

public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) => type.InvokeMember(name, invokeAttr, binder, target, args);

public override bool IsDefined(Type attributeType, bool inherit) => type.IsDefined(attributeType, inherit);

protected override TypeAttributes GetAttributeFlagsImpl() => (TypeAttributes)MethodGetAttributeFlagsImpl.Invoke(type, null);

protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) => (ConstructorInfo)MethodGetConstructorImpl.Invoke(type, new object[] { bindingAttr, binder, callConvention, type, modifiers });

protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) => (MethodInfo)MethodGetMethodImpl.Invoke(type, new object[] { name, bindingAttr, binder, callConvention, type, modifiers });

protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) => (PropertyInfo)MethodGetPropertyImpl.Invoke(type, new object[] { name, bindingAttr, binder, returnType, type, modifiers });

protected override bool HasElementTypeImpl() => (bool)MethodHasElementTypeImpl.Invoke(type, null);

protected override bool IsArrayImpl() => (bool)MethodIsArrayImpl.Invoke(type, null);

protected override bool IsByRefImpl() => (bool)MethodIsByRefImpl.Invoke(type, null);

protected override bool IsCOMObjectImpl() => (bool)MethodIsCOMObjectImpl.Invoke(type, null);

protected override bool IsPointerImpl() => (bool)MethodIsPointerImpl.Invoke(type, null);

protected override bool IsPrimitiveImpl() => (bool)MethodIsPrimitiveImpl.Invoke(type, null);

public IEnumerable<Type> GenericTypeArguments => type.GetGenericArguments();
}
}
76 changes: 76 additions & 0 deletions src/Core(3.5)/FatturaElettronica.Core(3.5).csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FatturaElettronica.Core</RootNamespace>
<AssemblyName>FatturaElettronica.Core</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Core\BaseClass.cs">
<Link>BaseClass.cs</Link>
</Compile>
<Compile Include="..\Core\BaseClassSerializable.cs">
<Link>BaseClassSerializable.cs</Link>
</Compile>
<Compile Include="..\Core\DataPropertyAttribute.cs">
<Link>DataPropertyAttribute.cs</Link>
</Compile>
<Compile Include="..\Core\IgnoreXmlDateFormat.cs">
<Link>IgnoreXmlDateFormat.cs</Link>
</Compile>
<Compile Include="..\Core\JsonOptions.cs">
<Link>JsonOptions.cs</Link>
</Compile>
<Compile Include="..\Core\JsonParseException.cs">
<Link>JsonParseException.cs</Link>
</Compile>
<Compile Include="..\Core\TypeExtensions.cs">
<Link>TypeExtensions.cs</Link>
</Compile>
<Compile Include="..\Core\XmlOptions.cs">
<Link>XmlOptions.cs</Link>
</Compile>
<Compile Include="Compatibily\CompilerServices.cs" />
<Compile Include="Compatibily\Reflection.cs" />
<Compile Include="Compatibily\TypeInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
36 changes: 36 additions & 0 deletions src/Core(3.5)/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FatturaElettronica.NET")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CIR 2000")]
[assembly: AssemblyProduct("FatturaElettronica.NET")]
[assembly: AssemblyCopyright("Copyright © CIR2000 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]


// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("555a2179-aeb8-4b3d-aa3f-92ee3dc9fe62")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 4 additions & 0 deletions src/Core(3.5)/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net35" />
</packages>
4 changes: 2 additions & 2 deletions src/Core/BaseClassSerializable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public virtual string ToJson()
public virtual string ToJson(JsonOptions jsonOptions)
{
var json = JsonConvert.SerializeObject(
this, (jsonOptions == JsonOptions.Indented) ? Formatting.Indented : Formatting.None,
this, (jsonOptions == JsonOptions.Indented) ? Newtonsoft.Json.Formatting.Indented : Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize, DefaultValueHandling = DefaultValueHandling.Ignore });
return json;
}
Expand Down Expand Up @@ -443,7 +443,7 @@ private static void ReadXmlList(object propertyValue, Type propertyType, string
// list items are expected to be of BusinessObject type.
var bo = Activator.CreateInstance(argumentType);
((BaseClassSerializable)bo).ReadXml(r);
add.Invoke(propertyValue, new[] { bo });
add.Invoke(propertyValue, new object [] { bo });
continue;
}

Expand Down
24 changes: 23 additions & 1 deletion src/FatturaElettronica.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ VisualStudioVersion = 15.0.26730.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FatturaElettronica.Core", "Core\FatturaElettronica.Core.csproj", "{157BF9FE-D002-4129-91A9-E4D1C74BE861}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{778645B6-7E1F-4BAD-8488-8C110A91620C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{778645B6-7E1F-4BAD-8488-8C110A91620C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FatturaElettronica.Core(3.5)", "Core(3.5)\FatturaElettronica.Core(3.5).csproj", "{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetStandard", "NetStandard", "{092D6860-DF60-48E2-BBF5-291B6B507480}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NET35", "NET35", "{494A9D17-FD4F-40CC-8B6F-01D7DFC935CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test(3.5)", "Test(3.5)\Test(3.5).csproj", "{2AFBF850-0A3F-4265-9A3F-066A2D731E61}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,10 +29,24 @@ Global
{778645B6-7E1F-4BAD-8488-8C110A91620C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{778645B6-7E1F-4BAD-8488-8C110A91620C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{778645B6-7E1F-4BAD-8488-8C110A91620C}.Release|Any CPU.Build.0 = Release|Any CPU
{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62}.Release|Any CPU.Build.0 = Release|Any CPU
{2AFBF850-0A3F-4265-9A3F-066A2D731E61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AFBF850-0A3F-4265-9A3F-066A2D731E61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AFBF850-0A3F-4265-9A3F-066A2D731E61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AFBF850-0A3F-4265-9A3F-066A2D731E61}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{157BF9FE-D002-4129-91A9-E4D1C74BE861} = {092D6860-DF60-48E2-BBF5-291B6B507480}
{778645B6-7E1F-4BAD-8488-8C110A91620C} = {092D6860-DF60-48E2-BBF5-291B6B507480}
{555A2179-AEB8-4B3D-AA3F-92EE3DC9FE62} = {494A9D17-FD4F-40CC-8B6F-01D7DFC935CB}
{2AFBF850-0A3F-4265-9A3F-066A2D731E61} = {494A9D17-FD4F-40CC-8B6F-01D7DFC935CB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EFA5152C-5656-48BA-B46F-226DE0764CD1}
EndGlobalSection
Expand Down
8 changes: 8 additions & 0 deletions src/Test(3.5)/Compatibility/NUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NUnit.Framework
{

public class TestClass : TestFixtureAttribute { }

public class TestMethod : TestAttribute { }

}
36 changes: 36 additions & 0 deletions src/Test(3.5)/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Test(3.5)")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test(3.5)")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2afbf850-0a3f-4265-9a3f-066a2d731e61")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 6576543

Please sign in to comment.