diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a2238d --- /dev/null +++ b/.gitignore @@ -0,0 +1,245 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +[Xx]64/ +[Xx]86/ +[Bb]uild/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml + +# TODO: Un-comment the next line if you do not want to checkin +# your web deploy settings because they may include unencrypted +# passwords +#*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# LightSwitch generated files +GeneratedArtifacts/ +ModelManifest.xml + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ \ No newline at end of file diff --git a/AsyncConverter.sln b/AsyncConverter.sln new file mode 100644 index 0000000..0909554 --- /dev/null +++ b/AsyncConverter.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncConverter", "AsyncConverter\AsyncConverter.csproj", "{2B4D3E14-B056-432E-B04C-C1DE571FD641}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2B4D3E14-B056-432E-B04C-C1DE571FD641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B4D3E14-B056-432E-B04C-C1DE571FD641}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B4D3E14-B056-432E-B04C-C1DE571FD641}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B4D3E14-B056-432E-B04C-C1DE571FD641}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/AsyncConverter/AsyncConverter.csproj b/AsyncConverter/AsyncConverter.csproj new file mode 100644 index 0000000..547b1c6 --- /dev/null +++ b/AsyncConverter/AsyncConverter.csproj @@ -0,0 +1,328 @@ + + + + + Debug + AnyCPU + {2B4D3E14-B056-432E-B04C-C1DE571FD641} + Library + Properties + AsyncConverter + AsyncConverter + v4.6.1 + 512 + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Antlr2.Runtime.2.7.7.02\lib\antlr.runtime.dll + True + + + ..\packages\AsyncBridge.JetBrains.0.1.1.0\lib\net40-Client\AsyncBridge.dll + True + + + ..\packages\AsyncIO.0.1.18.0\lib\net40\AsyncIO.dll + True + + + ..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll + True + + + ..\packages\JetBrains.Platform.Lib.DevExpress.2.0.20150224.0\lib\Net\DevExpress.Data.v7.1.dll + True + + + ..\packages\JetBrains.Platform.Lib.DevExpress.2.0.20150224.0\lib\Net\DevExpress.Utils.v7.1.dll + True + + + ..\packages\JetBrains.Platform.Lib.DevExpress.2.0.20150224.0\lib\Net\DevExpress.XtraEditors.v7.1.dll + True + + + ..\packages\JetBrains.Platform.Lib.DevExpress.2.0.20150224.0\lib\Net\DevExpress.XtraTreeList.v7.1.dll + True + + + ..\packages\SharpZipLib.JetBrains.Stripped.0.86.20150204.1\lib\20\ICSharpCode.SharpZipLib.dll + True + + + ..\packages\DotNetZip.Reduced.1.9.1.8\lib\net20\Ionic.Zip.Reduced.dll + True + + + ..\packages\JetBrains.Annotations.10.1.5\lib\net\JetBrains.Annotations.dll + True + + + ..\packages\JetBrains.Platform.Lib.Microsoft.Deployment.Compression.Cab.2.0.20140304.0\lib\Microsoft.Deployment.Compression.dll + True + + + ..\packages\JetBrains.Platform.Lib.Microsoft.Deployment.Compression.Cab.2.0.20140304.0\lib\Microsoft.Deployment.Compression.Cab.dll + True + + + ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll + True + + + ..\packages\Windows7APICodePack.JetBrains.Stripped.1.1.20150225.0\lib\Net\Microsoft.WindowsAPICodePack.dll + True + + + ..\packages\Windows7APICodePack.JetBrains.Stripped.1.1.20150225.0\lib\Net\Microsoft.WindowsAPICodePack.Shell.dll + True + + + ..\packages\JetBrains.Mono.Posix.0.1\lib\net40\Mono.Posix.dll + True + + + ..\packages\NetMQ.3.3.3.1\lib\net40\NetMQ.dll + True + + + ..\packages\Newtonsoft35.Json.7.0.1\lib\net35\Newtonsoft.Json.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Client.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Commands.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Common.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Configuration.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.ContentModel.dll + True + + + ..\packages\NuGet.Core.2.12.0\lib\net40-Client\NuGet.Core.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.DependencyResolver.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.DependencyResolver.Core.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Frameworks.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.LibraryModel.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Logging.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.PackageManagement.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Packaging.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Packaging.Core.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Packaging.Core.Types.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.ProjectManagement.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.ProjectModel.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Protocol.Core.Types.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Protocol.Core.v2.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Protocol.Core.v3.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Protocol.VisualStudio.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Repositories.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Resolver.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.RuntimeModel.dll + True + + + ..\packages\NuGet.Core.Ultimate.3.3.2\lib\net45\NuGet.Versioning.dll + True + + + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + + ..\packages\NVelocity.1.0.3\lib\NVelocity.dll + True + + + ..\packages\Sprache.JetBrains.2.0.0.44\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid1+MonoTouch1\Sprache.dll + True + + + + + + + + + + + + + + ..\packages\JetBrains.Platform.Lib.System.Windows.Interactivity.2.0.20140318.0\lib\System.Windows.Interactivity.dll + True + + + + + + + + + ..\packages\Vestris.ResourceLib.JetBrains.1.4.20150303.0\lib\Net\Vestris.ResourceLib.dll + True + + + + ..\packages\JetBrains.Platform.Lib.WpfContrib.2.0.20150225.0\lib\Net\WpfContrib.dll + True + + + ..\packages\xunit.JetBrains.1.9.2\lib\net20\xunit.dll + True + + + ..\packages\xunit.abstractions.JetBrains.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\packages\xunit.runner.utility.JetBrains.2.2.0\lib\net35\xunit.runner.utility.desktop.dll + True + + + + + + + + + + + + + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "$(SolutionDir)packages\NuGet.CommandLine.3.4.3\tools\nuget.exe" pack "$(SolutionDir)$(ProjectName)\package.nuspec" + + + \ No newline at end of file diff --git a/AsyncConverter/FixReturnValueToTask.cs b/AsyncConverter/FixReturnValueToTask.cs new file mode 100644 index 0000000..6136297 --- /dev/null +++ b/AsyncConverter/FixReturnValueToTask.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JetBrains.Application.Progress; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Daemon.CSharp.Errors; +using JetBrains.ReSharper.Feature.Services.CSharp.Analyses.Bulbs; +using JetBrains.ReSharper.Feature.Services.Daemon; +using JetBrains.ReSharper.Feature.Services.QuickFixes; +using JetBrains.ReSharper.Psi; +using JetBrains.ReSharper.Psi.CSharp; +using JetBrains.ReSharper.Psi.CSharp.Impl; +using JetBrains.ReSharper.Psi.CSharp.Tree; +using JetBrains.ReSharper.Psi.Impl.Types; +using JetBrains.ReSharper.Psi.Resolve; +using JetBrains.ReSharper.Psi.Tree; +using JetBrains.ReSharper.Psi.Util; +using JetBrains.TextControl; +using JetBrains.Util; + +namespace AsyncConverter +{ + [QuickFix] + public class FixReturnValueToTask : QuickFixBase + { + private readonly IncorrectArgumentTypeError error; + private ICSharpTypeConversionRule cSharpTypeConversionRule; + + public FixReturnValueToTask(IncorrectArgumentTypeError error) + { + this.error = error; + } + + protected override Action ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) + { + var expression = error.Argument as ICSharpArgument; + if (expression == null) + return null; + + var file = expression.GetContainingFile() as ICSharpFile; + if (file == null) + return null; + + var psiModule = error.Reference.GetAccessContext().GetPsiModule(); + cSharpTypeConversionRule = expression.GetTypeConversionRule(); + var factory = CSharpElementFactory.GetInstance(psiModule); + var cSharpArgument = factory.CreateArgument(ParameterKind.VALUE, factory.CreateExpression("Task.FromResult($0)", expression)); + expression.ReplaceBy(cSharpArgument); + var taskUsing = factory.CreateUsingDirective("System.Threading.Tasks"); + if(file.ImportsEnumerable.OfType().All(i => i.ImportedSymbolName.QualifiedName != "System.Threading.Tasks")) + file.AddImport(taskUsing, true); + return null; + } + + public override string Text => "Replace to Task.FromResult"; + + public override bool IsAvailable(IUserDataHolder cache) + { + var parameterType = error.ParameterType; + var parameterTypeClass = parameterType.GetClassType(); + + if (parameterTypeClass == null || parameterTypeClass.GetClrName().FullName != "System.Threading.Tasks.Task`1") + return false; + + var scalarType = parameterType.GetScalarType(); + if (scalarType == null) + return false; + + var substitution = scalarType.GetSubstitution(); + if (substitution.IsEmpty()) + return false; + + var firstGenericParameterType = substitution.Apply(substitution.Domain[0]); + + var argumentType = error.ArgumentType.ToIType(); + if (argumentType == null) + return false; + + return argumentType.IsSubtypeOf(firstGenericParameterType); + } + } +} diff --git a/AsyncConverter/Properties/AssemblyInfo.cs b/AsyncConverter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2cfeea5 --- /dev/null +++ b/AsyncConverter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Управление общими сведениями о сборке осуществляется с помощью +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("AsyncConverter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AsyncConverter")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми +// для COM-компонентов. Если требуется обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("2b4d3e14-b056-432e-b04c-c1de571fd641")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AsyncConverter/ZoneMarker.cs b/AsyncConverter/ZoneMarker.cs new file mode 100644 index 0000000..d905a10 --- /dev/null +++ b/AsyncConverter/ZoneMarker.cs @@ -0,0 +1,7 @@ +using JetBrains.Application.BuildScript.Application.Zones; + +namespace AsyncConverter +{ + [ZoneMarker] + public class ZoneMarker { } +} \ No newline at end of file diff --git a/AsyncConverter/app.config b/AsyncConverter/app.config new file mode 100644 index 0000000..3d025da --- /dev/null +++ b/AsyncConverter/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/AsyncConverter/package.nuspec b/AsyncConverter/package.nuspec new file mode 100644 index 0000000..c09954b --- /dev/null +++ b/AsyncConverter/package.nuspec @@ -0,0 +1,21 @@ + + + + AsyncConverter.AsyncConverter + AsyncConverter + 1.0.1 + i.mamay + i.mamay + i.mamay + false + AsyncConverter for test + AsyncConverter for test + + + + + + + + + \ No newline at end of file diff --git a/AsyncConverter/packages.config b/AsyncConverter/packages.config new file mode 100644 index 0000000..b645d44 --- /dev/null +++ b/AsyncConverter/packages.config @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file