6 changed files with 237 additions and 0 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// 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("PortSD4AddInToSD5")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("PortSD4AddInToSD5")] |
||||
[assembly: AssemblyCopyright("Copyright 2012")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<AddIn name = "PortSD4AddInToSD5" |
||||
author = "Daniel Grunwald" |
||||
description = "Issue Providers that help porting SD4 AddIns to SD5"> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "PortSD4AddInToSD5.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path path = "/SharpDevelop/ViewContent/TextEditor/C#/IssueProviders"> |
||||
<Class id = "WorkbenchSingletonIssueProvider" |
||||
class = "PortSD4AddInToSD5.WorkbenchSingletonIssueProvider" /> |
||||
</Path> |
||||
</AddIn> |
||||
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{E2FD63DA-8478-4066-934C-DA82A852C83A}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>PortSD4AddInToSD5</RootNamespace> |
||||
<AssemblyName>PortSD4AddInToSD5</AssemblyName> |
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<OutputPath>..\..\AddIns\</OutputPath> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="PresentationCore" /> |
||||
<Reference Include="PresentationFramework" /> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Data.DataSetExtensions"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xaml" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsBase" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="PortSD4AddInToSD5.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="WorkbenchSingletonIssueProvider.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\src\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> |
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project> |
||||
<Name>ICSharpCode.NRefactory.CSharp</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\src\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> |
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> |
||||
<Name>ICSharpCode.NRefactory</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\src\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
</Project> |
||||
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel |
||||
* Date: 9/22/2012 |
||||
* Time: 12:42 PM |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.NRefactory.CSharp.Refactoring; |
||||
using ICSharpCode.NRefactory.CSharp.Resolver; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace PortSD4AddInToSD5 |
||||
{ |
||||
[IssueDescription ("Usage of SD4 WorkbenchSingleton", |
||||
Description = "Usage of SD4 WorkbenchSingleton", |
||||
Category = IssueCategories.Notifications, |
||||
Severity = Severity.Warning, |
||||
IssueMarker = IssueMarker.Underline)] |
||||
public class WorkbenchSingletonIssueProvider : ICodeIssueProvider |
||||
{ |
||||
public IEnumerable<CodeIssue> GetIssues (BaseRefactoringContext context) |
||||
{ |
||||
foreach (var invocationExpression in context.RootNode.Descendants.OfType<InvocationExpression>()) { |
||||
var rr = context.Resolve(invocationExpression); |
||||
var irr = rr as CSharpInvocationResolveResult; |
||||
if (irr == null) |
||||
continue; |
||||
switch (irr.Member.FullName) { |
||||
case "ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.AssertMainThread": |
||||
yield return Issue( |
||||
invocationExpression, |
||||
script => { |
||||
script.Replace(invocationExpression, |
||||
new IdentifierExpression("SD").Member("MainThread").Invoke("VerifyAccess")); |
||||
}); |
||||
break; |
||||
case "ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.SafeThreadAsyncCall": |
||||
if (invocationExpression.Arguments.Count == 1) { |
||||
// SD.MainThread.InvokeAsync(argument).FireAndForget();
|
||||
yield return Issue( |
||||
invocationExpression, |
||||
script => { |
||||
script.Replace(invocationExpression, |
||||
new IdentifierExpression("SD").Member("MainThread") |
||||
.Invoke("InvokeAsync", invocationExpression.Arguments.Single().Clone()) |
||||
.Invoke("FireAndForget")); |
||||
}); |
||||
} else { |
||||
yield return Issue(invocationExpression); |
||||
} |
||||
break; |
||||
case "ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.SafeThreadCall": |
||||
case "ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.SafeThreadFunction": |
||||
if (invocationExpression.Arguments.Count == 1) { |
||||
// SD.MainThread.InvokeIfRequired(argument);
|
||||
yield return Issue( |
||||
invocationExpression, |
||||
script => { |
||||
script.Replace(invocationExpression.Target, |
||||
new IdentifierExpression("SD").Member("MainThread").Member("InvokeIfRequired")); |
||||
}); |
||||
} else { |
||||
yield return Issue(invocationExpression); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
CodeIssue Issue(AstNode node, Action<Script> fix = null) |
||||
{ |
||||
return new CodeIssue("WorkbenchSingleton is obsolete", node.StartLocation, node.EndLocation, |
||||
fix != null ? new CodeAction("Use SD5 API", fix) : null); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue