private void AddToContextIfNotPresent(string fullPath, MetadataReferenceProperties properties)
 {
     if (!_paths.Contains(fullPath))
     {
         _context.AddMetadataReference(fullPath, properties);
         bool added = _paths.Add(fullPath);
         Assumes.True(added);
     }
 }
        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;
        }
Beispiel #3
0
 private void AddToContextIfNotPresent(string fullPath, MetadataReferenceProperties properties, IProjectLogger logger)
 {
     if (!_paths.Contains(fullPath))
     {
         logger.WriteLine("Adding reference '{0}'", fullPath);
         _context.AddMetadataReference(fullPath, properties);
         bool added = _paths.Add(fullPath);
         Assumes.True(added);
     }
 }
        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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }