logic: fix more Visual Studio plugin issues
* using .Net framework version 4.6.1 in all projects * implemented exception handling in VCFileWrapperFactory * moved logging in separate assembly * enabled logging in wrapper code
This commit is contained in:
+77
-13
@@ -1,24 +1,88 @@
|
||||
namespace VCProjectEngineWrapper
|
||||
using CoatiSoftware.SourcetrailPlugin.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VCProjectEngineWrapper
|
||||
{
|
||||
public static class VCFileWrapperFactory
|
||||
{
|
||||
private interface IFactoryModule
|
||||
{
|
||||
IVCFileWrapper Create(object wrapped);
|
||||
}
|
||||
|
||||
private class FactoryModule2017 : IFactoryModule
|
||||
{
|
||||
public IVCFileWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCFileWrapperVs2017(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private class FactoryModule2015 : IFactoryModule
|
||||
{
|
||||
public IVCFileWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCFileWrapperVs2015(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private class FactoryModule2013 : IFactoryModule
|
||||
{
|
||||
public IVCFileWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCFileWrapperVs2013(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private class FactoryModule2012 : IFactoryModule
|
||||
{
|
||||
public IVCFileWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCFileWrapperVs2012(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private static Queue<IFactoryModule> modules = null;
|
||||
|
||||
public static IVCFileWrapper create(object wrapped)
|
||||
{
|
||||
if (modules == null)
|
||||
{
|
||||
modules = new Queue<IFactoryModule>();
|
||||
|
||||
// One of these modules will be working for each version of Visual Studio.
|
||||
modules.Enqueue(new FactoryModule2017());
|
||||
modules.Enqueue(new FactoryModule2015());
|
||||
modules.Enqueue(new FactoryModule2013());
|
||||
modules.Enqueue(new FactoryModule2012());
|
||||
}
|
||||
|
||||
IVCFileWrapper wrapper = null;
|
||||
int testedModuleCount = 0;
|
||||
|
||||
wrapper = new VCFileWrapperVs2017(wrapped);
|
||||
while (wrapper == null && testedModuleCount < modules.Count)
|
||||
{
|
||||
try
|
||||
{
|
||||
wrapper = modules.Peek().Create(wrapped);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
wrapper = null;
|
||||
}
|
||||
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCFileWrapperVs2015(wrapped);
|
||||
}
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCFileWrapperVs2013(wrapped);
|
||||
}
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCFileWrapperVs2012(wrapped);
|
||||
testedModuleCount++;
|
||||
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
// Moving the failing module to the end of the queue.
|
||||
// This causes the working module to finall end up in front.
|
||||
IFactoryModule failedModule = modules.Dequeue();
|
||||
Logging.LogInfo("Discarcing " + failedModule.GetType().Name + " while creating file wrapper.");
|
||||
modules.Enqueue(failedModule);
|
||||
wrapper = null;
|
||||
}
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
|
||||
+6
-1
@@ -9,8 +9,9 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VCProjectEngineWrapper</RootNamespace>
|
||||
<AssemblyName>VCProjectEngineWrapperFactory</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -54,6 +55,10 @@
|
||||
<Compile Include="VCProjectWrapperFactory.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SourcetrailPluginUtility\SourcetrailPluginUtility.csproj">
|
||||
<Project>{604b5751-af34-4ff9-92c3-c85a6bcdf98e}</Project>
|
||||
<Name>SourcetrailPluginUtility</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\VCProjectEngineWrapperInterfaces\VCProjectEngineWrapperInterfaces.csproj">
|
||||
<Project>{f592db46-0c77-470b-aaf8-80c51f44380e}</Project>
|
||||
<Name>VCProjectEngineWrapperInterfaces</Name>
|
||||
|
||||
+72
-43
@@ -1,60 +1,89 @@
|
||||
using System;
|
||||
using CoatiSoftware.SourcetrailPlugin.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VCProjectEngineWrapper
|
||||
{
|
||||
public static class VCProjectWrapperFactory
|
||||
{
|
||||
private interface IFactoryModule
|
||||
{
|
||||
IVCProjectWrapper Create(object wrapped);
|
||||
}
|
||||
|
||||
private class FactoryModule2017 : IFactoryModule
|
||||
{
|
||||
public IVCProjectWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCProjectWrapperVs2017(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private class FactoryModule2015 : IFactoryModule
|
||||
{
|
||||
public IVCProjectWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCProjectWrapperVs2015(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private class FactoryModule2013 : IFactoryModule
|
||||
{
|
||||
public IVCProjectWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCProjectWrapperVs2013(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private class FactoryModule2012 : IFactoryModule
|
||||
{
|
||||
public IVCProjectWrapper Create(object wrapped)
|
||||
{
|
||||
return new VCProjectWrapperVs2012(wrapped);
|
||||
}
|
||||
}
|
||||
|
||||
private static Queue<IFactoryModule> modules = null;
|
||||
|
||||
public static IVCProjectWrapper create(object wrapped)
|
||||
{
|
||||
if (modules == null)
|
||||
{
|
||||
modules = new Queue<IFactoryModule>();
|
||||
|
||||
// One of these modules will be working for each version of Visual Studio.
|
||||
modules.Enqueue(new FactoryModule2017());
|
||||
modules.Enqueue(new FactoryModule2015());
|
||||
modules.Enqueue(new FactoryModule2013());
|
||||
modules.Enqueue(new FactoryModule2012());
|
||||
}
|
||||
|
||||
IVCProjectWrapper wrapper = null;
|
||||
int testedModuleCount = 0;
|
||||
|
||||
try
|
||||
while (wrapper == null && testedModuleCount < modules.Count)
|
||||
{
|
||||
try
|
||||
{
|
||||
wrapper = modules.Peek().Create(wrapped);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
wrapper = null;
|
||||
}
|
||||
|
||||
testedModuleCount++;
|
||||
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCProjectWrapperVs2017(wrapped);
|
||||
// Moving the failing module to the end of the queue.
|
||||
// This causes the working module to finall end up in front.
|
||||
IFactoryModule failedModule = modules.Dequeue();
|
||||
Logging.LogInfo("Discarcing " + failedModule.GetType().Name + " while creating project wrapper.");
|
||||
modules.Enqueue(failedModule);
|
||||
wrapper = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
wrapper = null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCProjectWrapperVs2015(wrapped);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
wrapper = null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCProjectWrapperVs2013(wrapped);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
wrapper = null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (wrapper == null || !wrapper.isValid())
|
||||
{
|
||||
wrapper = new VCProjectWrapperVs2012(wrapped);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
wrapper = null;
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user