Browse Source

Create AddIn that implements issue providers for SD4 -> SD5 API changes.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
974a39b86f
  1. 11
      SharpDevelop.Tests.sln
  2. 11
      SharpDevelop.sln
  3. 31
      samples/PortSD4AddInToSD5/Configuration/AssemblyInfo.cs
  4. 13
      samples/PortSD4AddInToSD5/PortSD4AddInToSD5.addin
  5. 90
      samples/PortSD4AddInToSD5/PortSD4AddInToSD5.csproj
  6. 81
      samples/PortSD4AddInToSD5/WorkbenchSingletonIssueProvider.cs

11
SharpDevelop.Tests.sln

@ -145,6 +145,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\A @@ -145,6 +145,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "src\AddIns\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortSD4AddInToSD5", "samples\PortSD4AddInToSD5\PortSD4AddInToSD5.csproj", "{E2FD63DA-8478-4066-934C-DA82A852C83A}"
EndProject
Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}"
EndProject
Global
@ -555,6 +557,14 @@ Global @@ -555,6 +557,14 @@ Global
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|x86.Build.0 = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|x86.ActiveCfg = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|x86.Build.0 = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|x86.ActiveCfg = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|Any CPU.Build.0 = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|x86.Build.0 = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -588,6 +598,7 @@ Global @@ -588,6 +598,7 @@ Global
{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{AF5E0DC1-1FA0-4346-A436-0C817C68F7C1} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{B3352C08-3CB4-4DD9-996F-B9DCE4356BB9} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{E2FD63DA-8478-4066-934C-DA82A852C83A} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{83F15BA7-8478-4664-81BB-A82F146D88B3} = {F208FF4F-E5D8-41D5-A7C7-B463976F156E}
{17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F208FF4F-E5D8-41D5-A7C7-B463976F156E}
{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94}

11
SharpDevelop.sln

@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "src\AddIns\ @@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "src\AddIns\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegExpTk", "src\AddIns\Misc\RegExpTk\Project\RegExpTk.csproj", "{64A3E5E6-90BF-47F6-94DF-68C94B62C817}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortSD4AddInToSD5", "samples\PortSD4AddInToSD5\PortSD4AddInToSD5.csproj", "{E2FD63DA-8478-4066-934C-DA82A852C83A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -465,6 +467,14 @@ Global @@ -465,6 +467,14 @@ Global
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|x86.Build.0 = Release|Any CPU
{984CC812-9470-4A13-AFF9-CC44068D666C}.Release|x86.ActiveCfg = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|x86.Build.0 = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Debug|x86.ActiveCfg = Debug|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|Any CPU.Build.0 = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|x86.Build.0 = Release|Any CPU
{E2FD63DA-8478-4066-934C-DA82A852C83A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -508,6 +518,7 @@ Global @@ -508,6 +518,7 @@ Global
{80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{F93E52FD-DA66-4CE5-A0CB-BCD902811122} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{E2FD63DA-8478-4066-934C-DA82A852C83A} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}

31
samples/PortSD4AddInToSD5/Configuration/AssemblyInfo.cs

@ -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.*")]

13
samples/PortSD4AddInToSD5/PortSD4AddInToSD5.addin

@ -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>

90
samples/PortSD4AddInToSD5/PortSD4AddInToSD5.csproj

@ -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>

81
samples/PortSD4AddInToSD5/WorkbenchSingletonIssueProvider.cs

@ -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…
Cancel
Save