Skip to content

Commit

Permalink
silverlight 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
AqlaSolutions committed Jan 13, 2016
1 parent aad7bbb commit a12d758
Show file tree
Hide file tree
Showing 15 changed files with 1,436 additions and 40 deletions.
1 change: 1 addition & 0 deletions Nuget/runsharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This package is a fork of TriAxis.RunSharp (the original is now abandoned).</des
<tags>runsharp reflection reflection.emit compilation IKVM aqla aqlasolutions IL</tags>
<language>en-US</language>
<releaseNotes>
* 0.2.0.4 - added support for Silverlight 4
* 0.2.0.3 - added support for Windows Phone 8
* 0.2.0.0 - initial fork release:
- added IKVM support
Expand Down
36 changes: 36 additions & 0 deletions RunSharp.Tests.Silverlight/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("RunSharp.Tests.IKVM")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RunSharp.Tests.IKVM")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[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("d6f7ce55-853f-4e64-92c9-60c380bfb02f")]

// 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")]
67 changes: 67 additions & 0 deletions RunSharp.Tests.Silverlight/RunSharp.Tests.Silverlight.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{D6F7CA55-853F-4E68-92C9-60C0804FB02D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RunSharp.Tests.Silverlight</RootNamespace>
<AssemblyName>RunSharp.Tests.Silverlight</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;SILVERLIGHT</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;SILVERLIGHT</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="IKVM.Reflection">
<HintPath>..\lib\IKVM.Reflection.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RunSharpSilverlight\RunSharp_Silverlight.csproj">
<Project>{35031fc5-65e0-4f14-8dbc-a3140e940c14}</Project>
<Name>RunSharp_Silverlight</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\RunSharp.TestsShared\RunSharp.Tests.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
10 changes: 8 additions & 2 deletions RunSharp.TestsShared/Infrastructure/ExecutableTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Security.Policy;
using System.Text;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
Expand Down Expand Up @@ -108,8 +109,13 @@ public void RunTest(Generator test, bool exe)
#if !FEAT_IKVM
if (!exe)
{
#if SILVERLIGHT
Type entryType = asm.GetAssembly().DefinedTypes.First(t => t.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) != null);
#else
Type entryType = ((TypeBuilder)asm.GetAssembly().EntryPoint.DeclaringType).CreateType();
MethodInfo entryMethod = entryType.GetMethod(asm.GetAssembly().EntryPoint.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
#endif

MethodInfo entryMethod = entryType.GetMethod(asm.GetAssembly().EntryPoint?.Name ?? "Main", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
object[] entryArgs = null;
if (entryMethod.GetParameters().Length == 1)
{
Expand All @@ -125,7 +131,7 @@ public void RunTest(Generator test, bool exe)
AppDomain.CurrentDomain.ExecuteAssembly(exeFilePath, null, GetTestArguments(test));
#endif

Console.WriteLine("<<< END {0}", testName);
Console.WriteLine("<<< END {0}", testName);
Console.WriteLine();
}
}
Expand Down
2 changes: 2 additions & 0 deletions RunSharp.TestsShared/Infrastructure/TestingFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public class TestingFacade

public static IEnumerable<Action> GetTestsForGenerator(ExecutableTestHelper.Generator method, string expectedOutput)
{
#if !SILVERLIGHT
yield return () =>
{
ConsoleTester.ClearAndStartCapturing();
ExecutableTestHelper.RunTest(method, true);
ConsoleTester.AssertAndClear(expectedOutput);
};
#endif
#if !FEAT_IKVM
yield return () =>
{
Expand Down
32 changes: 32 additions & 0 deletions RunSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunSharp_WP8", "RunSharpWP8
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunSharp.Tests.WP8", "RunSharp.Tests.WP8\RunSharp.Tests.WP8.csproj", "{D6F74455-A53E-4E64-92C9-60C3803FB02F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunSharp_Silverlight", "RunSharpSilverlight\RunSharp_Silverlight.csproj", "{35031FC5-65E0-4F14-8DBC-A3140E940C14}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunSharp.Tests.Silverlight", "RunSharp.Tests.Silverlight\RunSharp.Tests.Silverlight.csproj", "{D6F7CA55-853F-4E68-92C9-60C0804FB02D}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
RunSharp.TestsShared\RunSharp.Tests.projitems*{6b5d07f1-94f2-4add-8931-7188b3a142bd}*SharedItemsImports = 4
RunSharpShared\RunSharpShared.projitems*{9fc6ca0f-d5d7-4c23-83a2-e910e5ba4f6f}*SharedItemsImports = 4
RunSharpShared\RunSharpShared.projitems*{35031fc5-65e0-4f14-8dbc-a3140e940c14}*SharedItemsImports = 4
RunSharp.TestsShared\RunSharp.Tests.projitems*{9225df43-7709-4522-afca-f01df2bf6e83}*SharedItemsImports = 13
RunSharp.TestsShared\RunSharp.Tests.projitems*{d6f7ce55-853f-4e64-92c9-60c380bfb02f}*SharedItemsImports = 4
RunSharp.TestsShared\RunSharp.Tests.projitems*{d6f7ca55-853f-4e68-92c9-60c0804fb02d}*SharedItemsImports = 4
RunSharpShared\RunSharpShared.projitems*{c835bb75-7955-4315-b52c-fa59e25219f4}*SharedItemsImports = 4
RunSharpShared\RunSharpShared.projitems*{1be6ac53-2c95-466e-b1d2-61e31493f169}*SharedItemsImports = 13
RunSharpShared\RunSharpShared.projitems*{08f134ae-48e8-4a35-9dc7-2f31eaf4a66f}*SharedItemsImports = 4
Expand Down Expand Up @@ -113,6 +119,30 @@ Global
{D6F74455-A53E-4E64-92C9-60C3803FB02F}.Release|ARM.Build.0 = Release|Any CPU
{D6F74455-A53E-4E64-92C9-60C3803FB02F}.Release|x86.ActiveCfg = Release|Any CPU
{D6F74455-A53E-4E64-92C9-60C3803FB02F}.Release|x86.Build.0 = Release|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Debug|ARM.ActiveCfg = Debug|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Debug|ARM.Build.0 = Debug|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Debug|x86.ActiveCfg = Debug|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Debug|x86.Build.0 = Debug|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Release|Any CPU.Build.0 = Release|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Release|ARM.ActiveCfg = Release|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Release|ARM.Build.0 = Release|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Release|x86.ActiveCfg = Release|Any CPU
{35031FC5-65E0-4F14-8DBC-A3140E940C14}.Release|x86.Build.0 = Release|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Debug|ARM.Build.0 = Debug|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Debug|x86.ActiveCfg = Debug|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Debug|x86.Build.0 = Debug|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Release|Any CPU.Build.0 = Release|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Release|ARM.ActiveCfg = Release|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Release|ARM.Build.0 = Release|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Release|x86.ActiveCfg = Release|Any CPU
{D6F7CA55-853F-4E68-92C9-60C0804FB02D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -126,5 +156,7 @@ Global
{D6F7CE55-853F-4E64-92C9-60C380BFB02F} = {387B3677-5A8B-4FB5-9FE3-2FD884DCF39D}
{9FC6CA0F-D5D7-4C23-83A2-E910E5BA4F6F} = {6348A303-6A2B-463E-A43F-C0C9617CCC37}
{D6F74455-A53E-4E64-92C9-60C3803FB02F} = {387B3677-5A8B-4FB5-9FE3-2FD884DCF39D}
{35031FC5-65E0-4F14-8DBC-A3140E940C14} = {6348A303-6A2B-463E-A43F-C0C9617CCC37}
{D6F7CA55-853F-4E68-92C9-60C0804FB02D} = {387B3677-5A8B-4FB5-9FE3-2FD884DCF39D}
EndGlobalSection
EndGlobal
3 changes: 1 addition & 2 deletions RunSharpIKVM/RunSharp_IKVM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\RunSharp\runsharp_key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="IKVM.Reflection">
Expand Down
47 changes: 39 additions & 8 deletions RunSharpShared/AssemblyGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ public DelegateGen Delegate(Type returnType, string name)

public AssemblyGen(string name, CompilerOptions options, ITypeMapper typeMapper = null)
{
Initialize(AppDomain.CurrentDomain, name, !Helpers.IsNullOrEmpty(options.OutputPath) ?AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run, options, typeMapper);
Initialize(AppDomain.CurrentDomain, name,
#if !SILVERLIGHT
!Helpers.IsNullOrEmpty(options.OutputPath) ? AssemblyBuilderAccess.RunAndSave :
#endif
AssemblyBuilderAccess.Run,
options, typeMapper);

}

Expand Down Expand Up @@ -293,7 +298,11 @@ void Initialize(Universe universe, string assemblyName, AssemblyBuilderAccess ac
ExpressionFactory = new ExpressionFactory(typeMapper);
StaticFactory = new StaticFactory(typeMapper);

#if SILVERLIGHT
bool save = false;
#else
bool save = (access & AssemblyBuilderAccess.Save) != 0;
#endif
string path = options.OutputPath;
if (path == null && save) throw new ArgumentNullException("options.OutputPath");

Expand All @@ -315,9 +324,11 @@ void Initialize(Universe universe, string assemblyName, AssemblyBuilderAccess ac
AssemblyName an = new AssemblyName();
an.Name = assemblyName;

AssemblyBuilder = path != null
? Universe.DefineDynamicAssembly(an, access, Path.GetDirectoryName(path))
: Universe.DefineDynamicAssembly(an, access);
AssemblyBuilder =
#if !SILVERLIGHT
path != null ? Universe.DefineDynamicAssembly(an, access, Path.GetDirectoryName(path)) :
#endif
Universe.DefineDynamicAssembly(an, access);
#if FEAT_IKVM
if (!Helpers.IsNullOrEmpty(options.KeyFile))
{
Expand All @@ -337,20 +348,30 @@ void Initialize(Universe universe, string assemblyName, AssemblyBuilderAccess ac
}
ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName, path, options.SymbolInfo);
#else
ModuleBuilder = save ? AssemblyBuilder.DefineDynamicModule(moduleName, Path.GetFileName(path)) : AssemblyBuilder.DefineDynamicModule(moduleName);
if (save)
{
#if !SILVERLIGHT
ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName, Path.GetFileName(path));
#else
throw new NotSupportedException("Can't save on this platform");
#endif
}
else
ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName);
#endif
}


public void Save()
{
Complete();

if ((_access & AssemblyBuilderAccess.Save) != 0)
#if !SILVERLIGHT
if ((_access & AssemblyBuilderAccess.Save) != 0)
#if FEAT_IKVM
AssemblyBuilder.Save(_fileName);
#else
AssemblyBuilder.Save(Path.GetFileName(_fileName));
#endif
#endif
}

Expand Down Expand Up @@ -446,8 +467,18 @@ public void Complete()

AttributeGen.ApplyList(ref _assemblyAttributes, AssemblyBuilder.SetCustomAttribute);
AttributeGen.ApplyList(ref _moduleAttributes, ModuleBuilder.SetCustomAttribute);
WriteAssemblyAttributes(_compilerOptions, AssemblyBuilder.GetName().Name, AssemblyBuilder);
WriteAssemblyAttributes(_compilerOptions, GetAssemblyName(), AssemblyBuilder);
}

string GetAssemblyName()
{
#if !SILVERLIGHT
return AssemblyBuilder.GetName().Name;
#else
return AssemblyBuilder.GetName(false).Name;
#endif
}

#endregion
}
}
Expand Down
8 changes: 4 additions & 4 deletions RunSharpShared/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RunSharp")]
[assembly: AssemblyCopyright("Copyright © 2007 Stefan Simek, Copyright © 2015 Vladyslav Taranov")]
[assembly: AssemblyCopyright("Copyright © 2007 Stefan Simek, Copyright © 2016 Vladyslav Taranov")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -57,11 +57,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.2.0.3")]
[assembly: AssemblyFileVersion("0.2.0.3")]
[assembly: AssemblyVersion("0.2.0.4")]
[assembly: AssemblyFileVersion("0.2.0.4")]

//[assembly: CLSCompliant(true)]
#if !PHONE8
#if !PHONE8 && !SILVERLIGHT
[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)]
[assembly: ReflectionPermission(SecurityAction.RequestMinimum, ReflectionEmit = true)]
#endif
Expand Down
12 changes: 8 additions & 4 deletions RunSharpShared/DynamicMethodGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ private DynamicMethodGen(Attributes attrs, Type returnType, ICodeGenBasicContext

protected override void CreateMember()
{
#if SILVERLIGHT
_dm = new DynamicMethod(_attrs.name, ReturnType, ParameterTypes);
#else
if (_attrs.ownerType != null)
try
{
Expand All @@ -148,6 +151,7 @@ protected override void CreateMember()
{
_dm = new DynamicMethod(_attrs.name, ReturnType, ParameterTypes, _attrs.OwnerModule, false);
}
#endif
}

protected override void RegisterMember()
Expand All @@ -174,7 +178,7 @@ public DynamicMethod GetCompletedDynamicMethod(bool completeIfNeeded)
return _dm;
}

#region RoutineGen concrete implementation
#region RoutineGen concrete implementation

protected override bool HasCode => true;

Expand Down Expand Up @@ -206,13 +210,13 @@ protected override void SetCustomAttribute(CustomAttributeBuilder cab)
throw new InvalidOperationException(Properties.Messages.ErrDynamicMethodNoCustomAttrs);
}

#endregion
#endregion

#region ICodeGenContext Members
#region ICodeGenContext Members

bool ICodeGenContext.SupportsScopes => false;

#endregion
#endregion
}
}
#endif
Loading

0 comments on commit a12d758

Please sign in to comment.