1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Rely on CS-Script includes for modules view model matching

This commit is contained in:
SpoinkyNL 2018-03-04 22:27:57 +01:00
parent 36b8ddc023
commit 2f72cdb1d9
21 changed files with 301 additions and 81 deletions

View File

@ -181,16 +181,20 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\DataModelProperty.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Events\DeviceEventArgs.cs" />
<Compile Include="Exceptions\ArtemisCoreException.cs" />
<Compile Include="Exceptions\ArtemisPluginException.cs" />
<Compile Include="Models\DataModelDescription.cs" />
<Compile Include="ProfileElements\Folder.cs" />
<Compile Include="ProfileElements\Interfaces\IProfileElement.cs" />
<Compile Include="ProfileElements\Profile.cs" />
<Compile Include="Ninject\CoreModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\Interfaces\IMainDataModelService.cs" />
<Compile Include="Services\CoreService.cs" />
<Compile Include="Services\MainDataModelService.cs" />
<Compile Include="Services\RgbService.cs" />
<Compile Include="Services\Interfaces\IRgbService.cs" />
<Compile Include="Services\Interfaces\IArtemisService.cs" />
@ -209,9 +213,7 @@
<Name>Artemis.Plugins</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Artemis.Core.Attributes
{
public class DataModelPropertyAttribute : Attribute
{
public string DisplayName { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Artemis.Core.Models
{
public class DataModelDescription
{
}
}

View File

@ -1,10 +1,12 @@
using System;
using Artemis.Core.Events;
namespace Artemis.Core.Services.Interfaces
{
public interface ICoreService: IArtemisService, IDisposable
public interface ICoreService : IArtemisService, IDisposable
{
/// <summary>
/// Indicates wether or not the core has been initialized
/// </summary>
bool IsInitialized { get; set; }
/// <summary>

View File

@ -0,0 +1,32 @@
using Artemis.Core.Models;
using Artemis.Plugins.Interfaces;
namespace Artemis.Core.Services.Interfaces
{
public interface IMainDataModelService : IArtemisService
{
/// <summary>
/// Called each frame when the main data model must update
/// </summary>
/// <param name="deltaTime">Time since the last update</param>
void Update(double deltaTime);
/// <summary>
/// Add an expansion to the datamodel to be available for use after the next update
/// </summary>
/// <param name="dataModelExpansion"></param>
void AddExpansion(IDataModelExpansion dataModelExpansion);
/// <summary>
/// Remove a previously added expansion so that it is no longer available and updated
/// </summary>
/// <param name="dataModelExpansion"></param>
void RemoveExpansion(IDataModelExpansion dataModelExpansion);
/// <summary>
/// Generates a data model description for the main datamodel including all it's expansions
/// </summary>
/// <returns>The generated data model description</returns>
DataModelDescription GetMainDataModelDescription();
}
}

View File

@ -0,0 +1,68 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Exceptions;
using Artemis.Core.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Interfaces;
namespace Artemis.Core.Services
{
public class MainDataModelService : IMainDataModelService
{
private readonly List<IDataModelExpansion> _dataModelExpansions;
public MainDataModelService()
{
_dataModelExpansions = new List<IDataModelExpansion>();
}
public ReadOnlyCollection<IDataModelExpansion> DataModelExpansions
{
get
{
lock (_dataModelExpansions)
{
return _dataModelExpansions.AsReadOnly();
}
}
}
public void Update(double deltaTime)
{
lock (_dataModelExpansions)
{
// Update all expansions
foreach (var expansion in _dataModelExpansions)
expansion.Update(deltaTime);
}
}
public void AddExpansion(IDataModelExpansion dataModelExpansion)
{
lock (_dataModelExpansions)
{
_dataModelExpansions.Add(dataModelExpansion);
// TODO SpoinkyNL 3-3-2018: Initialize the expansion and fire an event
}
}
public void RemoveExpansion(IDataModelExpansion dataModelExpansion)
{
lock (_dataModelExpansions)
{
if (!_dataModelExpansions.Contains(dataModelExpansion))
throw new ArtemisCoreException("Cannot remove a data model expansion that wasn't previously added.");
// TODO SpoinkyNL 3-3-2018: Dispose the expansion and fire an event
_dataModelExpansions.Remove(dataModelExpansion);
}
}
public DataModelDescription GetMainDataModelDescription()
{
var dataModelDescription = new DataModelDescription();
return dataModelDescription;
}
}
}

View File

@ -58,7 +58,7 @@ namespace Artemis.Core.Services
/// <inheritdoc />
public async Task<IModuleViewModel> GetModuleViewModel(PluginInfo pluginInfo)
{
return await pluginInfo.GetModuleViewModel(_kernel);
return pluginInfo.GetModuleViewModel(_kernel);
}
public void Dispose()

View File

@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>5</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -47,15 +48,16 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<None Include="Modules\General\GeneralModule.cs" />
<None Include="Modules\General\GeneralViewModel.cs" />
<Compile Include="Modules\General\GeneralModule.cs" />
<Compile Include="Modules\General\GeneralViewModel.cs" />
<Compile Include="Modules\General\GeneralDataModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Modules\General\GeneralView.xaml">
<Page Include="Modules\General\GeneralView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</None>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />

View File

@ -0,0 +1,12 @@
using System;
using Artemis.Core.Attributes;
using Artemis.Plugins.Interfaces;
namespace Artemis.Plugins.BuiltIn.Modules.General
{
public class GeneralDataModel : IModuleDataModel
{
[DataModelProperty(DisplayName = "Unique boolean")]
public bool PropertyUniqueToThisDm { get; set; }
}
}

View File

@ -1,34 +1,22 @@
using System.Diagnostics;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Interfaces;
//css_inc GeneralViewModel.cs;
//css_inc GeneralDataModel.cs;
using System;
using Artemis.Plugins.Abstract;
namespace Artemis.Plugins.BuiltIn.Modules.General
{
public class GeneralModule : IModule
public class GeneralModule : ProfileModule
{
private readonly ICoreService _coreService;
public GeneralModule(ICoreService coreService)
public override Type ViewModelType
{
_coreService = coreService;
Debugger.Break();
get { return typeof(GeneralViewModel); }
}
public void LoadPlugin()
{
}
public void UnloadPlugin()
{
}
public void Update(double deltaTime)
{
}
public void Render(double deltaTime)
// True since the main data model is all this module shows
public override bool ExpandsMainDataModel
{
get { return true; }
}
}
}

View File

@ -1,6 +1,5 @@
{
"Name": "Default",
"Version": "1.0.0",
"Main": "GeneralModule.cs",
"ViewModel": "GeneralViewModel.cs"
"Main": "GeneralModule.cs"
}

View File

@ -32,7 +32,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
<bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
@ -40,6 +40,30 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.Scripting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp.Scripting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>

View File

@ -0,0 +1,38 @@
using System;
using Artemis.Plugins.Interfaces;
namespace Artemis.Plugins.Abstract
{
public abstract class ProfileModule : IModule
{
/// <inheritdoc />
public abstract Type ViewModelType { get; }
/// <inheritdoc />
public abstract bool ExpandsMainDataModel { get; }
/// <inheritdoc />
public void LoadPlugin()
{
// Load and activate the last active profile
}
/// <inheritdoc />
public void UnloadPlugin()
{
// Unload the last active profile
}
/// <inheritdoc />
public virtual void Update(double deltaTime)
{
// Update the profile
}
/// <inheritdoc />
public virtual void Render(double deltaTime)
{
// Render the profile
}
}
}

View File

@ -11,6 +11,8 @@
<AssemblyName>Artemis.Plugins</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -33,17 +35,17 @@
<Reference Include="CSScriptLibrary, Version=3.28.0.0, Culture=neutral, PublicKeyToken=70fcc3d18c749033, processorArchitecture=MSIL">
<HintPath>..\packages\CS-Script.bin.3.28.0.1\lib\net46\CSScriptLibrary.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp.Scripting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.CSharp.Scripting, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.Scripting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll</HintPath>
<Reference Include="Microsoft.CodeAnalysis.Scripting, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.6.1\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll</HintPath>
</Reference>
<Reference Include="Mono.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\CS-Script.bin.3.28.0.1\lib\net46\Mono.CSharp.dll</HintPath>
@ -135,11 +137,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Abstract\ModuleViewModel.cs" />
<Compile Include="Abstract\ProfileModule.cs" />
<Compile Include="Exceptions\ArtemisPluginException.cs" />
<Compile Include="Interfaces\IDataModelExpansion.cs" />
<Compile Include="Interfaces\IDevice.cs" />
<Compile Include="Interfaces\ILayerType.cs" />
<Compile Include="Interfaces\IModule.cs" />
<Compile Include="Interfaces\IModuleDataModel.cs" />
<Compile Include="Interfaces\IPlugin.cs" />
<Compile Include="Interfaces\IModuleViewModel.cs" />
<Compile Include="Models\PluginInfo.cs" />

View File

@ -6,5 +6,6 @@
/// </summary>
public interface IDataModelExpansion : IPlugin
{
void Update(double deltaTime);
}
}

View File

@ -1,4 +1,7 @@
namespace Artemis.Plugins.Interfaces
using System;
using Ninject;
namespace Artemis.Plugins.Interfaces
{
/// <inheritdoc />
/// <summary>
@ -6,6 +9,17 @@
/// </summary>
public interface IModule : IPlugin
{
/// <summary>
/// The type of this module's view model
/// </summary>
Type ViewModelType { get; }
/// <summary>
/// Wether or not this module expands upon the main data model. If set to true any data in main data model can be
/// accessed by profiles in this module
/// </summary>
bool ExpandsMainDataModel { get; }
/// <summary>
/// Called each frame when the module must update
/// </summary>

View File

@ -0,0 +1,7 @@
namespace Artemis.Plugins.Interfaces
{
public interface IModuleDataModel
{
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
@ -14,6 +13,8 @@ namespace Artemis.Plugins.Models
{
public class PluginInfo : IDisposable
{
private static Assembly _assembly;
/// <summary>
/// The name of the plugin
/// </summary>
@ -29,11 +30,6 @@ namespace Artemis.Plugins.Models
/// </summary>
public string Main { get; set; }
/// <summary>
/// The file implementing IPluginViewModel, loaded when opened in the UI
/// </summary>
public string ViewModel { get; set; }
/// <summary>
/// The instantiated plugin, available after successful load
/// </summary>
@ -46,12 +42,6 @@ namespace Artemis.Plugins.Models
[JsonIgnore]
public string Folder { get; set; }
/// <summary>
/// Indicates wether this is a built-in plugin.
/// </summary>
[JsonIgnore]
public bool IsBuiltIn { get; private set; }
public void Dispose()
{
Plugin.UnloadPlugin();
@ -68,7 +58,7 @@ namespace Artemis.Plugins.Models
// Make sure the right engine is used
CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
CSScript.EvaluatorConfig.DebugBuild = true;
CSScript.GlobalSettings.SearchDirs = folder;
if (!folder.EndsWith("\\"))
folder += "\\";
if (!File.Exists(folder + "plugin.json"))
@ -78,8 +68,8 @@ namespace Artemis.Plugins.Models
pluginInfo.Folder = folder;
// Load the main script and get the type
var assembly = await CSScript.Evaluator.CompileCodeAsync(File.ReadAllText(folder + pluginInfo.Main));
var pluginType = assembly.GetTypes().Where(t => typeof(IPlugin).IsAssignableFrom(t)).ToList();
_assembly = await CSScript.Evaluator.CompileCodeAsync(File.ReadAllText(folder + pluginInfo.Main));
var pluginType = _assembly.GetTypes().Where(t => typeof(IPlugin).IsAssignableFrom(t)).ToList();
if (!pluginType.Any())
throw new ArtemisPluginException(pluginInfo, "Failed to load plugin, no type found that implements IPlugin");
if (pluginType.Count > 1)
@ -91,33 +81,27 @@ namespace Artemis.Plugins.Models
return pluginInfo;
}
/// <summary>
/// Gets the view model of the module accompanying the provided plugin info
/// </summary>
/// <param name="kernel">The Ninject kernel to use for DI</param>
/// <returns></returns>
public async Task<IModuleViewModel> GetModuleViewModel(IKernel kernel)
public IModuleViewModel GetModuleViewModel(IKernel kernel)
{
// Make sure the right engine is used
CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
CSScript.EvaluatorConfig.DebugBuild = true;
// Don't attempt to locave VMs for something other than a module
if (!(Plugin is IModule))
if (Plugin == null)
throw new ArtemisPluginException(this, "Cannot locate a view model for this plugin because it's not compiled.");
if (!(Plugin is IModule module))
throw new ArtemisPluginException(this, "Cannot locate a view model for this plugin as it's not a module.");
// Use the plugin's assembly as the VM is precompiled if built in, otherwise compile the VM into a new assembly
var assembly = await CSScript.Evaluator.CompileCodeAsync(File.ReadAllText(Folder + ViewModel));
var vmType = assembly.GetTypes().Where(t => typeof(IModuleViewModel).IsAssignableFrom(t)).ToList();
if (!vmType.Any())
throw new ArtemisPluginException(this, "Failed to load plugin, no type found that implements IModuleViewModel");
if (vmType.Count > 1)
throw new ArtemisPluginException(this, "Failed to load plugin, more than one type found that implements IModuleViewModel");
// Get the type from the module
var vmType = module.ViewModelType;
if (!typeof(IModuleViewModel).IsAssignableFrom(vmType))
throw new ArtemisPluginException(this, "ViewModel must implement IModuleViewModel.");
// Instantiate the ViewModel with Ninject
var vm = (IModuleViewModel) kernel.Get(vmType.First());
var vm = (IModuleViewModel) kernel.Get(vmType);
vm.PluginInfo = this;
return vm;
}

View File

@ -34,6 +34,22 @@
<assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.Scripting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp.Scripting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -2,10 +2,11 @@
<packages>
<package id="CS-Script.bin" version="3.28.0.1" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.Common" version="2.0.0" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.0.0" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.CSharp.Scripting" version="2.0.0" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.Scripting.Common" version="2.0.0" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.Common" version="2.6.1" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.6.1" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.CSharp.Scripting" version="2.6.1" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.Scripting" version="2.6.1" targetFramework="net46" />
<package id="Microsoft.CodeAnalysis.Scripting.Common" version="2.6.1" targetFramework="net46" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net46" />
<package id="Ninject" version="3.3.4" targetFramework="net46" />
<package id="Stylet" version="1.1.21" targetFramework="net46" />

View File

@ -22,8 +22,9 @@ namespace Artemis.UI.Stylet
private UIElement CreateViewForPlugin(object model)
{
var viewName = model.GetType().Name.Replace("Model", "");
var pluginInfo = ((IModuleViewModel) model).PluginInfo;
var viewPath = pluginInfo.Folder + pluginInfo.ViewModel.Replace("ViewModel", "View").Replace(".cs", ".xaml");
var viewPath = $"{pluginInfo.Folder}{viewName}.xaml";
// There doesn't have to be a view so make sure one exists
if (!File.Exists(viewPath))
return null;