private void RemoveFromContextIfPresent(string fullPath)
 {
     if (_paths.Contains(fullPath))
     {
         _context.RemoveMetadataReference(fullPath);
         bool removed = _paths.Remove(fullPath);
         Assumes.True(removed);
     }
 }
        private void AddToContextIfNotPresent(string fullPath, MetadataReferenceProperties properties, IProjectLogger logger)
        {
            if (_addedPathsWithMetadata.TryGetValue(fullPath, out var existingProperties))
            {
                logger.WriteLine("Removing existing reference with '{0}' so we can update the aliases.", fullPath);

                // The reference has already been added previously. The current implementation of IWorkspaceProjectContext
                // presumes that we'll only called AddMetadataReference once for a given path. Thus we have to remove the
                // existing one, compute merged properties, and add the new one.
                _context.RemoveMetadataReference(fullPath);

                var combinedAliases = GetEmptyIfGlobalAlias(GetGlobalAliasIfEmpty(existingProperties.Aliases).AddRange(GetGlobalAliasIfEmpty(properties.Aliases)));
                properties = properties.WithAliases(combinedAliases);
            }

            logger.WriteLine("Adding reference '{0}'", fullPath);
            _context.AddMetadataReference(fullPath, properties);
            _addedPathsWithMetadata[fullPath] = properties;
        }
Exemplo n.º 3
0
 private void RemoveFromContextIfPresent(string fullPath, IProjectLogger logger)
 {
     if (_paths.Contains(fullPath))
     {
         logger.WriteLine("Removing reference '{0}'", fullPath);
         _context.RemoveMetadataReference(fullPath);
         bool removed = _paths.Remove(fullPath);
         Assumes.True(removed);
     }
 }
        public void Handle(CommandLineArguments added, CommandLineArguments removed)
        {
            Requires.NotNull(added, nameof(added));
            Requires.NotNull(removed, nameof(removed));

            foreach (CommandLineReference reference in removed.MetadataReferences)
            {
                _context.RemoveMetadataReference(reference.Reference);
            }

            foreach (CommandLineReference reference in added.MetadataReferences)
            {
                _context.AddMetadataReference(reference.Reference, reference.Properties);
            }
        }
Exemplo n.º 5
0
        public void Handle(CommandLineArguments added, CommandLineArguments removed, IWorkspaceProjectContext context, bool isActiveContext)
        {
            Requires.NotNull(added, nameof(added));
            Requires.NotNull(removed, nameof(removed));

            foreach (CommandLineReference reference in removed.MetadataReferences)
            {
                context.RemoveMetadataReference(reference.Reference);
            }

            foreach (CommandLineReference reference in added.MetadataReferences)
            {
                context.AddMetadataReference(reference.Reference, reference.Properties);
            }
        }
Exemplo n.º 6
0
        public void Handle(BuildOptions added, BuildOptions removed, IWorkspaceProjectContext context, bool isActiveContext)
        {
            Requires.NotNull(added, nameof(added));
            Requires.NotNull(removed, nameof(removed));

            foreach (CommandLineReference reference in removed.MetadataReferences)
            {
                var fullPath = _unconfiguredProject.MakeRooted(reference.Reference);
                context.RemoveMetadataReference(fullPath);
            }

            foreach (CommandLineReference reference in added.MetadataReferences)
            {
                var fullPath = _unconfiguredProject.MakeRooted(reference.Reference);
                context.AddMetadataReference(fullPath, reference.Properties);
            }
        }