示例#1
0
            private async Task HandleReferenceAssemblyReferenceAsync(
                IPackageInstallerService installerService,
                List <Reference> allReferences,
                TSimpleNameSyntax nameNode,
                Project project,
                bool isAttributeSearch,
                PackageWithTypeResult result,
                int weight,
                CancellationToken cancellationToken)
            {
                foreach (var reference in project.MetadataReferences)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);

                    var assemblySymbol = compilation.GetAssemblyOrModuleSymbol(reference) as IAssemblySymbol;
                    if (assemblySymbol?.Name == result.AssemblyName)
                    {
                        // Project already has a reference to an assembly with this name.
                        return;
                    }
                }

                var desiredName = GetDesiredName(isAttributeSearch, result);

                allReferences.Add(new AssemblyReference(_owner, installerService,
                                                        new SearchResult(desiredName, nameNode, result.ContainingNamespaceNames, weight), result));
            }
示例#2
0
            private void HandleNugetReference(
                string source,
                ArrayBuilder <Reference> allReferences,
                TSimpleNameSyntax nameNode,
                bool isAttributeSearch,
                PackageWithTypeResult result,
                int weight
                )
            {
                var desiredName = GetDesiredName(isAttributeSearch, result.TypeName);

                allReferences.Add(
                    new PackageReference(
                        _owner,
                        new SearchResult(
                            desiredName,
                            nameNode,
                            result.ContainingNamespaceNames.ToReadOnlyList(),
                            weight
                            ),
                        source,
                        result.PackageName,
                        result.Version
                        )
                    );
            }
 public AssemblyReference(
     AbstractAddImportCodeFixProvider <TSimpleNameSyntax> provider,
     IPackageInstallerService installerService,
     SearchResult searchResult,
     PackageWithTypeResult packageWithType)
     : base(provider, searchResult)
 {
     _packageWithType = packageWithType;
 }
示例#4
0
 public static SerializablePackageWithTypeResult Dehydrate(PackageWithTypeResult result)
 {
     return(new SerializablePackageWithTypeResult
     {
         PackageName = result.PackageName,
         TypeName = result.TypeName,
         Version = result.Version,
         Rank = result.Rank,
         ContainingNamespaceNames = result.ContainingNamespaceNames.ToArray(),
     });
 }
示例#5
0
            private static string GetDesiredName(bool isAttributeSearch, PackageWithTypeResult result)
            {
                var desiredName = result.TypeName;

                if (isAttributeSearch)
                {
                    desiredName = desiredName.GetWithoutAttributeSuffix(isCaseSensitive: false);
                }

                return(desiredName);
            }
示例#6
0
            private Task HandleNugetReferenceAsync(
                string source,
                IPackageInstallerService installerService,
                List <Reference> allReferences,
                TSimpleNameSyntax nameNode,
                Project project,
                bool isAttributeSearch,
                PackageWithTypeResult result,
                int weight)
            {
                if (!installerService.IsInstalled(project.Solution.Workspace, project.Id, result.PackageName))
                {
                    var desiredName = GetDesiredName(isAttributeSearch, result.TypeName);
                    allReferences.Add(new PackageReference(_owner, installerService,
                                                           new SearchResult(desiredName, nameNode, result.ContainingNamespaceNames, weight),
                                                           source, result.PackageName, result.Version));
                }

                return(SpecializedTasks.EmptyTask);
            }