public VisualStudioFileCache(ICacheEventHelper cacheEventHelper, IVisualStudioEventProxy visualStudioEventProxy, IFileWrapper fileWrapper, IVisualStudioOpenDocumentManager openDocumentManager)
        {
            _fileWrapper = fileWrapper;
            _openDocumentManager = openDocumentManager;

            WireUpCacheEvictionEvents(cacheEventHelper, visualStudioEventProxy);
        }
 public VisualStudioCodeGenerator(IVisualStudioWriter visualStudioWriter, IPartialCodeGenerator codeGenerator, ICodeGeneratorContextFactory codeGeneratorContextFactory, IVisualStudioEventProxy visualStudioEventProxy)
 {
     _visualStudioWriter = visualStudioWriter;
     _codeGenerator = codeGenerator;
     _codeGeneratorContextFactory = codeGeneratorContextFactory;
     _visualStudioEventProxy = visualStudioEventProxy;
 }
        public CSharpFileFactory(IFileReader fileReader, ICacheEventHelper cacheEventHelper, IVisualStudioEventProxy visualStudioEventProxy, IVisualStudioOpenDocumentManager openDocumentManager)
        {
            _fileReader = fileReader;
            _openDocumentManager = openDocumentManager;

            WireUpCacheEvictionEvents(cacheEventHelper, visualStudioEventProxy);
        }
        public VisualStudioOpenDocumentManager(IVisualStudioEventProxy eventProxy)
        {
            eventProxy.OnProjectItemOpened += (sender, args) =>
            {
                _log.InfoFormat("Document Opened [{0}]", args.ClassFullPath);

                _openDocuments.AddOrUpdate(
                    args.ClassFullPath,
                    (x) => args.DocumentReader,
                    (x, y) => args.DocumentReader);
            };

            eventProxy.OnProjectItemClosed += (sender, args) =>
            {
                _log.InfoFormat("Document Closed [{0}]", args.ClassFullPath);

                IVisualStudioOpenDocumentReader dummy;

                if (!_openDocuments.TryRemove(args.ClassFullPath, out dummy))
                    _log.WarnFormat("Recevied a Close event but Window was not in Cache [{0}]",
                        args.ClassFullPath);
            };

            eventProxy.OnSolutionClosing += (sender, args) =>
            {
                _log.Info("Solution Closing.  Clearing Cache");

                _openDocuments = new ConcurrentDictionary<FilePath, IVisualStudioOpenDocumentReader>();
            };
        }
        public pMixinsOnBuildCodeGenerator(IVisualStudioEventProxy visualStudioEventProxy, IVisualStudioCodeGenerator visualStudioCodeGenerator, ICodeGeneratorContextFactory codeGeneratorContextFactory, IpMixinsCodeGeneratorResponseFileWriter responseFileWriter)
        {
            _visualStudioCodeGenerator = visualStudioCodeGenerator;
            _codeGeneratorContextFactory = codeGeneratorContextFactory;
            _responseFileWriter = responseFileWriter;

            visualStudioEventProxy.OnBuildBegin += HandleBuild;
        }
        public pMixinsOnSolutionOpenCodeGenerator(IVisualStudioEventProxy visualStudioEventProxy, ICodeGeneratorContextFactory codeGeneratorContextFactory, IpMixinsCodeGeneratorResponseFileWriter responseFileWriter, ITaskFactory taskFactory, IVisualStudioCodeGenerator visualStudioCodeGenerator)
        {
            _codeGeneratorContextFactory = codeGeneratorContextFactory;
            _responseFileWriter = responseFileWriter;
            _taskFactory = taskFactory;
            _visualStudioCodeGenerator = visualStudioCodeGenerator;

            visualStudioEventProxy.OnSolutionOpening += (s, a) => WarmUpCodeGeneratorDependencyManager();

            visualStudioEventProxy.OnSolutionClosing += (s, a) => OnSolutionOpeningTask = null;
        }
        private void WireUpVisualStudioEvents(IVisualStudioEventProxy visualStudioEventProxy,
            ICodeGeneratorDependencyFactory codeGeneratorDependencyFactory)
        {
            CodeGeneratorDependency dummy;

            visualStudioEventProxy.OnCodeGenerated += (sender, args) =>
            {
                var dependency = codeGeneratorDependencyFactory.BuildDependency(args.Response);

                if (null != dependency)
                    //Add Dependency
                    _codeGeneratorDependencies.AddOrUpdate(
                        dependency.TargetFile.FileName,
                        dependency,
                        (s, d) => dependency);

                else if (
                    null != args.Response &&
                    null != args.Response.CodeGeneratorContext &&
                    null != args.Response.CodeGeneratorContext.Source &&
                    !args.Response.CodeGeneratorContext.Source.FileName.IsNullOrEmpty())
                    //Remove Dependency
                    _codeGeneratorDependencies.TryRemove(
                        args.Response.CodeGeneratorContext.Source.FileName,
                        out dummy);
            };

            visualStudioEventProxy.OnProjectItemRemoved += (sender, args) =>
            {
                if (_codeGeneratorDependencies.TryRemove(
                    args.ClassFullPath,
                    out dummy))
                {
                    _log.InfoFormat("Evicted [{0}]", args.ClassFullPath);
                }
            };

            visualStudioEventProxy.OnSolutionClosing +=
                (sender, args) =>
                {
                    _log.Info("Solution closing.  Clearing cache");

                    _codeGeneratorDependencies =
                        new ConcurrentDictionary<FilePath, CodeGeneratorDependency>();
                };
        }
 public VisualStudioEventProxyLogger(IVisualStudioEventProxy eventProxy)
 {
     eventProxy.OnBuildBegin += (o, a) => LogEventArgs(a);
     eventProxy.OnBuildDone += (o, a) => LogEventArgs(a);
     eventProxy.OnCodeGenerated += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectAdded += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemAdded += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemClosed += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemOpened += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemRemoved += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemRenamed += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemSaveComplete += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectItemSaved += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectReferenceAdded += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectReferenceRemoved += (o, a) => LogEventArgs(a);
     eventProxy.OnProjectRemoved += (o, a) => LogEventArgs(a);
     eventProxy.OnSolutionClosing += (o, a) => _log.Debug("Solution Closing");
     eventProxy.OnSolutionOpening += (o, a) => _log.Debug("Solution Opening");
 }
        public static void Initialize(IVisualStudioWriter visualStudioWriter, IVisualStudioEventProxy visualStudioEventProxy, ICodeBehindFileHelper codeBehindFileHelper, ISolutionFileReader dteSolutionFileReader)
        {
            Kernel = new StandardKernel(
                new StandardModule(),
                new pMixinsStandardModule());

            Kernel.Bind<IVisualStudioWriter>().ToMethod(c => visualStudioWriter).InSingletonScope();

            Kernel.Bind<IVisualStudioEventProxy>().ToMethod(c => visualStudioEventProxy).InSingletonScope();

            Kernel.Bind<ICodeBehindFileHelper>().ToMethod(c => codeBehindFileHelper);

            Kernel.Rebind<ISolutionFileReader>().ToMethod(c => dteSolutionFileReader);

            LoggingActivity.Initialize(visualStudioWriter);

            //Make sure the VisualStudioOpenDocumentManager loads early
            Kernel.Get<IVisualStudioOpenDocumentManager>();
        }
 public SolutionManager(string solutionName, IVisualStudioEventProxy visualStudioEvents)
     : this(new NRefactory.Solution(solutionName), visualStudioEvents)
 {
 }
 public CachedMicrosoftBuildProjectAssemblyReferenceResolver(IVisualStudioEventProxy visualStudioEventProxy, IMicrosoftBuildProjectLoader buildProjectLoader, ITaskFactory taskFactory)
 {
     _buildProjectLoader = buildProjectLoader;
     _taskFactory        = taskFactory;
     WireUpVisualStudioEvents(visualStudioEventProxy);
 }
 public MicrosoftBuildProjectLoader(IVisualStudioEventProxy visualStudioEventProxy)
 {
     //Make sure there aren't any latent project references
     visualStudioEventProxy.OnProjectRemoved += (sender, args) =>
         RemoveAllReferencesToProject(args.ProjectFullPath);
 }
        private void WireUpVisualStudioEvents(IVisualStudioEventProxy visualStudioEventProxy)
        {
            IAssemblyReference[] dummy;

            visualStudioEventProxy.OnSolutionClosing +=
                (sender, args) =>
                {
                    _log.Info("Solution closing.  Clearing cache");
                    _cache = new ConcurrentDictionary<FilePath, IAssemblyReference[]>();
                };

            visualStudioEventProxy.OnProjectAdded +=
                (sender, args) =>
                {
                    if (_cache.TryRemove(args.ProjectFullPath, out dummy))
                        _log.InfoFormat("Evicted [{0}]", args.ProjectFullPath);

                    //This can cause problems if the project added event is in response to
                    //a project reload.
                    //EagerlyResolveReferences(args.ProjectFullPath);
                };

            visualStudioEventProxy.OnProjectReferenceAdded +=
                (sender, args) =>
                {
                    if (_cache.TryRemove(args.ProjectFullPath, out dummy))
                        _log.InfoFormat("Evicted [{0}]", args.ProjectFullPath);

                    EagerlyResolveReferences(args.ProjectFullPath);
                };

            visualStudioEventProxy.OnProjectReferenceRemoved +=
                (sender, args) =>
                {
                    if (_cache.TryRemove(args.ProjectFullPath, out dummy))
                        _log.InfoFormat("Evicted [{0}]", args.ProjectFullPath);

                    EagerlyResolveReferences(args.ProjectFullPath);
                };

            visualStudioEventProxy.OnProjectRemoved +=
                (sender, args) =>
                {
                    if (_cache.TryRemove(args.ProjectFullPath, out dummy))
                        _log.InfoFormat("Evicted [{0}]", args.ProjectFullPath);
                };
        }
 public TestMicrosoftBuildProjectAssemblyReferenceResolver(IVisualStudioEventProxy visualStudioEventProxy, IMicrosoftBuildProjectLoader buildProjectLoader, ITaskFactory taskFactory)
     : base(visualStudioEventProxy, buildProjectLoader, taskFactory)
 {
 }
 public TestMicrosoftBuildProjectAssemblyReferenceResolver(IVisualStudioEventProxy visualStudioEventProxy, IMicrosoftBuildProjectLoader buildProjectLoader, ITaskFactory taskFactory) : base(visualStudioEventProxy, buildProjectLoader, taskFactory)
 {
 }
        public CacheEventHelper(IVisualStudioEventProxy visualStudioEventProxy, ICodeGeneratorDependencyManager codeGeneratorDependencyManager, ISolutionContext solutionContext)
        {
            AddEmptyEventHandlers();

            WireUpVisualStudioEvents(visualStudioEventProxy, codeGeneratorDependencyManager, solutionContext);
        }
 public SolutionManager(NRefactory.Solution solution, IVisualStudioEventProxy visualStudioEvents)
     : this(new SolutionExtender(solution), visualStudioEvents)
 {
 }
        public SolutionManager(ISolutionExtender solutionExtender, IVisualStudioEventProxy visualStudioEvents)
        {
            Ensure.ArgumentNotNull(solutionExtender, "solutionExtender");
            Ensure.ArgumentNotNull(visualStudioEvents, "visualStudioEvents");

            SolutionExtender = solutionExtender;
            _visualStudioEvents = visualStudioEvents;

            WireUpVisualStudioEvents(_visualStudioEvents);
        }
        private void WireUpVisualStudioEvents(IVisualStudioEventProxy proxy)
        {
            proxy.OnProjectAdded += QueueVisualStudioEvent;
            proxy.OnProjectRemoved += QueueVisualStudioEvent;
            proxy.OnProjectReferenceAdded += QueueVisualStudioEvent;
            proxy.OnProjectReferenceRemoved += QueueVisualStudioEvent;
            proxy.OnProjectItemAdded += QueueVisualStudioEvent;
            proxy.OnProjectItemRemoved += QueueVisualStudioEvent;
            proxy.OnProjectItemRenamed += QueueVisualStudioEvent;
            proxy.OnProjectItemSaved += QueueVisualStudioEvent;

            proxy.OnProjectItemOpened += (sender, args) =>
                                         {
                                             if (!_codeGeneratedFileNames.Contains(args.ClassFullPath))
                                                 return;

                                             _log.InfoFormat(
                                                 "Eagerly 'EnsureSolutionIsFullyParsedAsync' in response to a File Opened event for [{0}]",
                                                 args.ClassFullPath);

                                             EnsureSolutionIsFullyParsedAsync();
                                         };
        }
        public CacheEventHelper(IVisualStudioEventProxy visualStudioEventProxy, ICodeGeneratorDependencyManager codeGeneratorDependencyManager, ISolutionContext solutionContext)
        {
            AddEmptyEventHandlers();

            WireUpVisualStudioEvents(visualStudioEventProxy, codeGeneratorDependencyManager, solutionContext);
        }
        private void WireUpCacheEvictionEvents(ICacheEventHelper cacheEventHelper, IVisualStudioEventProxy visualStudioEventProxy)
        {
            cacheEventHelper.OnClearCache +=
                (sender, args) =>
                {
                    _log.Info("Solution closing.  Clearing cache");
                    _fileCache = new ConcurrentDictionary<FilePath, CSharpFile>();

                    _fileByProjectIndex = new FileByProjectIndex();
                };

            cacheEventHelper.OnEvictFromCache +=
                (sender, args) =>
                {
                    CSharpFile dummy;

                    if (_fileCache.TryRemove(args.FileName, out dummy))
                        _log.InfoFormat("Evicted [{0}]", args.FileName);
                };

            visualStudioEventProxy.OnProjectRemoved +=
                (sender, args) => EvictAllFilesInProject(args.ProjectFullPath);

            //Evict files, their reference to the Project is no longer valid
            visualStudioEventProxy.OnProjectReferenceAdded +=
                (sender, args) => EvictAllFilesInProject(args.ProjectFullPath);

            //Evict files, their reference to the Project is no longer valid
            visualStudioEventProxy.OnProjectReferenceRemoved +=
                (sender, args) => EvictAllFilesInProject(args.ProjectFullPath);
        }
 public MicrosoftBuildProjectLoader(IVisualStudioEventProxy visualStudioEventProxy)
 {
     //Make sure there aren't any latent project references
     visualStudioEventProxy.OnProjectRemoved += (sender, args) =>
                                                RemoveAllReferencesToProject(args.ProjectFullPath);
 }
 public SolutionManager(NRefactory.Solution solution, IVisualStudioEventProxy visualStudioEvents)
     : this(new SolutionExtender(solution), visualStudioEvents)
 {
 }
 public CodeGeneratorDependencyManager(IVisualStudioEventProxy visualStudioEventProxy, ICodeGeneratorDependencyFactory codeGeneratorDependencyFactory)
 {
     WireUpVisualStudioEvents(visualStudioEventProxy, codeGeneratorDependencyFactory);
 }
        private void WireUpVisualStudioEvents(IVisualStudioEventProxy visualStudioEventProxy,
                                              ICodeGeneratorDependencyManager codeGeneratorDependencyManager, ISolutionContext solutionContext)
        {
            visualStudioEventProxy.OnSolutionClosing +=
                (sender, args) =>
            {
                _log.Info("Solution closing.  Firing OnClearCache");
                OnClearCache(this, new EventArgs());
            };

            visualStudioEventProxy.OnProjectAdded +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectAdded - Evict [{0}]", solutionContext.SolutionFileName);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(solutionContext.SolutionFileName));
            };

            visualStudioEventProxy.OnProjectRemoved +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectRemoved - Evict [{0}]", args.ProjectFullPath);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ProjectFullPath));

                _log.InfoFormat("OnProjectRemoved - Evict [{0}]", solutionContext.SolutionFileName);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(solutionContext.SolutionFileName));
            };

            visualStudioEventProxy.OnProjectReferenceAdded +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectReferenceAdded - Evict [{0}]", args.ProjectFullPath);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ProjectFullPath));

                //TODO - Evict Project Items - Compilation needs to be updated?
            };

            visualStudioEventProxy.OnProjectReferenceRemoved +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectReferenceRemoved - Evict [{0}]", args.ProjectFullPath);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ProjectFullPath));

                //TODO - Evict Project Items - Compilation needs to be updated?
            };

            visualStudioEventProxy.OnProjectItemSaved +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectItemSaved - Evict [{0}]", args.ClassFullPath);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ClassFullPath));

                codeGeneratorDependencyManager
                .GetFilesThatDependOn(args.ClassFullPath)
                .Map(f =>
                {
                    _log.InfoFormat("OnProjectItemSaved - Evict Dependency [{0}]", f.FileName);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(f.FileName)
                    {
                        FileOnDiskHasChanged = false
                    });
                });
            };

            visualStudioEventProxy.OnProjectItemRemoved +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectItemRemoved - Evict [{0}]", args.ClassFullPath);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ClassFullPath));
            };

            visualStudioEventProxy.OnProjectItemRenamed +=
                (sender, args) =>
            {
                _log.InfoFormat("OnProjectItemRemoved - Evict [{0}]", args.OldClassFileName);

                OnEvictFromCache(this, new EvictFromCacheEventArgs(args.OldClassFileName));
            };
        }
 public CachedMicrosoftBuildProjectAssemblyReferenceResolver(IVisualStudioEventProxy visualStudioEventProxy, IMicrosoftBuildProjectLoader buildProjectLoader, ITaskFactory taskFactory)
 {
     _buildProjectLoader = buildProjectLoader;
     _taskFactory = taskFactory;
     WireUpVisualStudioEvents(visualStudioEventProxy);
 }
Exemple #27
0
        public CSharpFileFactory(IFileReader fileReader, ICacheEventHelper cacheEventHelper, IVisualStudioEventProxy visualStudioEventProxy, IVisualStudioOpenDocumentManager openDocumentManager)
        {
            _fileReader          = fileReader;
            _openDocumentManager = openDocumentManager;

            WireUpCacheEvictionEvents(cacheEventHelper, visualStudioEventProxy);
        }
        private void WireUpCacheEvictionEvents(ICacheEventHelper cacheEventHelper, IVisualStudioEventProxy visualStudioEventProxy)
        {
            cacheEventHelper.OnEvictFromCache += (sender, args) =>
            {
                if (!args.FileOnDiskHasChanged)
                    return;

                FileReaderAsync dummy;

                if (_fileCache.TryRemove(args.FileName, out dummy))
                    _log.InfoFormat("Evicted [{0}]", args.FileName);
            };

            cacheEventHelper.OnClearCache += (sender, args) =>
            {
                _fileCache = new ConcurrentDictionary<FilePath, FileReaderAsync>();

                _log.InfoFormat("Cleared Cache");
            };

            visualStudioEventProxy.OnProjectItemAdded +=
                (sender, args) => TryEagerlyLoadFile(args.ClassFullPath);

            visualStudioEventProxy.OnProjectItemRenamed +=
                (sender, args) => TryEagerlyLoadFile(args.ClassFullPath);
        }
 public SolutionManager(string solutionName, IVisualStudioEventProxy visualStudioEvents)
     : this(new NRefactory.Solution(solutionName), visualStudioEvents)
 {
 }
        private void WireUpVisualStudioEvents(IVisualStudioEventProxy visualStudioEventProxy,
            ICodeGeneratorDependencyManager codeGeneratorDependencyManager, ISolutionContext solutionContext)
        {
            visualStudioEventProxy.OnSolutionClosing +=
                (sender, args) =>
                {
                    _log.Info("Solution closing.  Firing OnClearCache");
                    OnClearCache(this, new EventArgs());
                };

            visualStudioEventProxy.OnProjectAdded +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectAdded - Evict [{0}]", solutionContext.SolutionFileName);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(solutionContext.SolutionFileName));
                };

            visualStudioEventProxy.OnProjectRemoved +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectRemoved - Evict [{0}]", args.ProjectFullPath);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ProjectFullPath));

                    _log.InfoFormat("OnProjectRemoved - Evict [{0}]", solutionContext.SolutionFileName);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(solutionContext.SolutionFileName));
                };

            visualStudioEventProxy.OnProjectReferenceAdded +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectReferenceAdded - Evict [{0}]", args.ProjectFullPath);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ProjectFullPath));

                    //TODO - Evict Project Items - Compilation needs to be updated?
                };

            visualStudioEventProxy.OnProjectReferenceRemoved +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectReferenceRemoved - Evict [{0}]", args.ProjectFullPath);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ProjectFullPath));

                    //TODO - Evict Project Items - Compilation needs to be updated?
                };

            visualStudioEventProxy.OnProjectItemSaved +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectItemSaved - Evict [{0}]", args.ClassFullPath);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ClassFullPath));

                    codeGeneratorDependencyManager
                        .GetFilesThatDependOn(args.ClassFullPath)
                        .Map(f =>
                        {
                            _log.InfoFormat("OnProjectItemSaved - Evict Dependency [{0}]", f.FileName);

                            OnEvictFromCache(this, new EvictFromCacheEventArgs(f.FileName)
                            {
                                FileOnDiskHasChanged = false
                            });
                        });
                };

            visualStudioEventProxy.OnProjectItemRemoved +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectItemRemoved - Evict [{0}]", args.ClassFullPath);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(args.ClassFullPath));
                };

            visualStudioEventProxy.OnProjectItemRenamed +=
                (sender, args) =>
                {
                    _log.InfoFormat("OnProjectItemRemoved - Evict [{0}]", args.OldClassFileName);

                    OnEvictFromCache(this, new EvictFromCacheEventArgs(args.OldClassFileName));
                };
        }