-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
120 changed files
with
18,435 additions
and
3,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
*.userprefs | ||
.buildvars.py | ||
.sconsign.dblite | ||
.vs/config/* | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM ubuntu:xenial | ||
|
||
# Get dependencies | ||
RUN apt-get update && apt-get -y install build-essential cmake libcppunit-dev \ | ||
libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev \ | ||
libavutil-dev git mono-xbuild nuget mono-devel | ||
|
||
RUN mkdir /build | ||
WORKDIR /build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PluginTests | ||
{ | ||
class PluginA : IPlugin | ||
{ | ||
public void Initialize(MainClass mc) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?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>{DDBB1943-929D-43F6-A7E1-01903DD05D64}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>PluginTests</RootNamespace> | ||
<AssemblyName>PluginTests</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<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="PluginA.cs"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
using System; | ||
using System.CodeDom.Compiler; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Linq; | ||
|
||
namespace PluginTests | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var mc = new MainClass(); | ||
mc.LoadPlugin(new FileInfo("PluginA.cs")); | ||
} | ||
} | ||
|
||
public class MainClass | ||
{ | ||
public void Feature1() { } | ||
public void Feature2(int value) { int x = value + 10; var x2 = x.ToString().Split('1'); } | ||
public int Feature3() { return 42; } | ||
public MainClass Feature4() { return this; } | ||
|
||
private static readonly FileInfo ts3File = new FileInfo(typeof(IPlugin).Assembly.Location); | ||
public AppDomain domain; | ||
|
||
public PluginResponse LoadPlugin(FileInfo file) | ||
{ | ||
try | ||
{ | ||
if (file.Extension != ".cs" && file.Extension != ".dll" && file.Extension != ".exe") | ||
return PluginResponse.UnsupportedFile; | ||
|
||
domain = AppDomain.CreateDomain( | ||
"Plugin_" + file.Name, | ||
AppDomain.CurrentDomain.Evidence, | ||
new AppDomainSetup | ||
{ | ||
ShadowCopyFiles = "true", | ||
ShadowCopyDirectories = ts3File.Directory.FullName, | ||
ApplicationBase = ts3File.Directory.FullName, | ||
PrivateBinPath = "Plugin/..;Plugin", | ||
PrivateBinPathProbe = "" | ||
}); | ||
domain.UnhandledException += (s, e) => { Console.WriteLine("Plugin unex: {0}", e.ExceptionObject); }; | ||
|
||
//domain.Load() | ||
|
||
Assembly result; | ||
if (file.Extension == ".cs") | ||
result = PrepareSource(file); | ||
else if (file.Extension == ".dll" || file.Extension == ".exe") | ||
result = PrepareBinary(file); | ||
else throw new InvalidProgramException(); | ||
|
||
return PluginResponse.Ok; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine("Possible plugin failed to load: ", ex); | ||
return PluginResponse.Crash; | ||
} | ||
} | ||
|
||
private static CompilerParameters GenerateCompilerParameter() | ||
{ | ||
var cp = new CompilerParameters(); | ||
Assembly[] aarr = AppDomain.CurrentDomain.GetAssemblies(); | ||
for (int i = 0; i < aarr.Length; i++) | ||
{ | ||
if (aarr[i].IsDynamic) continue; | ||
cp.ReferencedAssemblies.Add(aarr[i].Location); | ||
} | ||
cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location); | ||
|
||
// set preferences | ||
cp.WarningLevel = 3; | ||
cp.CompilerOptions = "/target:library /optimize"; | ||
cp.GenerateExecutable = false; | ||
cp.GenerateInMemory = true; | ||
return cp; | ||
} | ||
|
||
private Assembly PrepareSource(FileInfo file) | ||
{ | ||
var provider = CodeDomProvider.CreateProvider("CSharp"); | ||
var cp = GenerateCompilerParameter(); | ||
var result = provider.CompileAssemblyFromFile(cp, file.FullName); | ||
|
||
if (result.Errors.Count > 0) | ||
{ | ||
bool containsErrors = false; | ||
foreach (CompilerError error in result.Errors) | ||
{ | ||
containsErrors |= !error.IsWarning; | ||
Console.WriteLine("Plugin_{0}: {1} L{2}/C{3}: {4}\n", | ||
file.Name, | ||
error.IsWarning ? "Warning" : "Error", | ||
error.Line, | ||
error.Column, | ||
error.ErrorText); | ||
} | ||
|
||
if (containsErrors) | ||
return null; | ||
} | ||
|
||
return result.CompiledAssembly; | ||
} | ||
|
||
private Assembly PrepareBinary(FileInfo file) | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
public interface IPlugin | ||
{ | ||
void Initialize(MainClass mc); | ||
} | ||
|
||
public enum PluginResponse | ||
{ | ||
Ok, | ||
UnsupportedFile, | ||
Crash, | ||
NoTypeMatch, | ||
TooManyPlugins, | ||
UnknownStatus, | ||
PluginNotFound, | ||
CompileError, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("PluginTests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("PluginTests")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[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("ddbb1943-929d-43f6-a7e1-01903dd05d64")] | ||
|
||
// 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")] |
Oops, something went wrong.