Ejemplo n.º 1
0
        private CodeAction TryCreateCodeAction(Document document, AddImportFixData fixData, IPackageInstallerService installerService)
        {
            switch (fixData.Kind)
            {
            case AddImportFixKind.ProjectSymbol:
                return(new ProjectSymbolReferenceCodeAction(document, fixData));

            case AddImportFixKind.MetadataSymbol:
                return(new MetadataSymbolReferenceCodeAction(document, fixData));

            case AddImportFixKind.ReferenceAssemblySymbol:
                return(new AssemblyReferenceCodeAction(document, fixData));

            case AddImportFixKind.PackageSymbol:
                return(!installerService.IsInstalled(document.Project.Solution.Workspace, document.Project.Id, fixData.PackageName)
                        ? new ParentInstallPackageCodeAction(document, fixData, installerService)
                        : null);
            }

            throw ExceptionUtilities.Unreachable;
        }
            private static CodeAction CreateCodeAction(
                Document document,
                AddImportFixData fixData,
                IPackageInstallerService installerService,
                string versionOpt,
                bool isLocal)
            {
                var title = versionOpt == null
                    ? FeaturesResources.Find_and_install_latest_version
                    : isLocal
                        ? string.Format(FeaturesResources.Use_local_version_0, versionOpt)
                        : string.Format(FeaturesResources.Install_version_0, versionOpt);

                var installOperation = new InstallPackageDirectlyCodeActionOperation(
                    installerService, document, fixData.PackageSource, fixData.PackageName, versionOpt,
                    includePrerelease: false, isLocal: isLocal);

                // Nuget hits should always come after other results.
                return(new InstallPackageAndAddImportCodeAction(
                           document, fixData, title, installOperation));
            }
Ejemplo n.º 3
0
            public override async Task <AddImportFixData> TryGetFixDataAsync(
                Document document,
                SyntaxNode node,
                bool placeSystemNamespaceFirst,
                bool allowInHiddenRegions,
                CancellationToken cancellationToken
                )
            {
                var textChanges = await GetTextChangesAsync(
                    document,
                    node,
                    placeSystemNamespaceFirst,
                    allowInHiddenRegions,
                    cancellationToken
                    )
                                  .ConfigureAwait(false);

                return(AddImportFixData.CreateForPackageSymbol(
                           textChanges,
                           _source,
                           _packageName,
                           _versionOpt
                           ));
            }
Ejemplo n.º 4
0
 public MetadataSymbolReferenceCodeAction(Document originalDocument, AddImportFixData fixData)
     : base(originalDocument, fixData)
 {
     Contract.ThrowIfFalse(fixData.Kind == AddImportFixKind.MetadataSymbol);
 }
 protected SymbolReferenceCodeAction(
     Document originalDocument,
     AddImportFixData fixData)
     : base(originalDocument, fixData)
 {
 }
Ejemplo n.º 6
0
 public AssemblyReferenceCodeAction(Document originalDocument, AddImportFixData fixData)
     : base(originalDocument, fixData)
 {
     Contract.ThrowIfFalse(fixData.Kind == AddImportFixKind.ReferenceAssemblySymbol);
 }