Ejemplo n.º 1
0
        public void Update(ProjectConfiguration projConfig, string framework, Project proj, MonoDevelopWorkspace.ProjectDataMap projectMap, ProjectCacheInfo info)
        {
            if (!loaded)
            {
                return;
            }

            var paths   = new string [info.SourceFiles.Length];
            var actions = new string [info.SourceFiles.Length];

            for (int i = 0; i < info.SourceFiles.Length; ++i)
            {
                paths [i]   = info.SourceFiles [i].FilePath;
                actions [i] = info.SourceFiles [i].BuildAction;
            }

            var projectRefs = new ReferenceItem [info.ProjectReferences.Length];

            for (int i = 0; i < info.ProjectReferences.Length; ++i)
            {
                var pr = info.ProjectReferences [i];
                (Project mdProject, string projectReferenceFramework) = projectMap.GetMonoProjectAndFramework(pr.ProjectId);
                projectRefs [i] = new ReferenceItem {
                    FilePath  = mdProject.FileName,
                    Aliases   = pr.Aliases.ToArray(),
                    Framework = projectReferenceFramework
                };
            }

            var item = new ProjectCache {
                Format             = format,
                AdditionalFiles    = info.AdditionalFiles.Select(x => (string)x).ToArray(),
                Analyzers          = info.AnalyzerFiles.Select(x => (string)x).ToArray(),
                EditorConfigFiles  = info.EditorConfigFiles.Select(x => (string)x).ToArray(),
                Files              = paths,
                BuildActions       = actions,
                MetadataReferences = info.References.Select(x => {
                    var ri = new ReferenceItem {
                        FilePath = x.FilePath,
                        Aliases  = x.Properties.Aliases.ToArray(),
                    };
                    return(ri);
                }).ToArray(),
                ProjectReferences = projectRefs,
            };

            string configId  = GetConfigId(projConfig);
            var    cacheFile = GetProjectCacheFile(proj, configId, framework);

            WriteCacheFile(item, cacheFile);
        }
Ejemplo n.º 2
0
        public void Update(ProjectConfiguration projConfig, string framework, Project proj, MonoDevelopWorkspace.ProjectDataMap projectMap,
                           ImmutableArray <ProjectFile> files,
                           ImmutableArray <FilePath> analyzers,
                           ImmutableArray <MonoDevelopMetadataReference> metadataReferences,
                           ImmutableArray <Microsoft.CodeAnalysis.ProjectReference> projectReferences)
        {
            if (!loaded)
            {
                return;
            }

            var paths   = new string [files.Length];
            var actions = new string [files.Length];

            for (int i = 0; i < files.Length; ++i)
            {
                paths [i]   = files [i].FilePath;
                actions [i] = files [i].BuildAction;
            }

            var projectRefs = new ReferenceItem [projectReferences.Length];

            for (int i = 0; i < projectReferences.Length; ++i)
            {
                var pr = projectReferences [i];
                (Project mdProject, string projectReferenceFramework) = projectMap.GetMonoProjectAndFramework(pr.ProjectId);
                projectRefs [i] = new ReferenceItem {
                    FilePath  = mdProject.FileName,
                    Aliases   = pr.Aliases.ToArray(),
                    Framework = projectReferenceFramework
                };
            }

            var item = new ProjectCache {
                Format             = format,
                Analyzers          = analyzers.Select(x => (string)x).ToArray(),
                Files              = paths,
                BuildActions       = actions,
                MetadataReferences = metadataReferences.Select(x => {
                    var ri = new ReferenceItem {
                        FilePath = x.FilePath,
                        Aliases  = x.Properties.Aliases.ToArray(),
                    };
                    return(ri);
                }).ToArray(),
                ProjectReferences = projectRefs,
            };

            string configId  = GetConfigId(projConfig);
            var    cacheFile = GetProjectCacheFile(proj, configId, framework);

            FileLock fileLock = AcquireWriteLock(cacheFile);

            try {
                lock (fileLock) {
                    var serializer = new JsonSerializer();
                    using (var fs = File.Open(cacheFile, FileMode.Create))
                        using (var sw = new StreamWriter(fs)) {
                            serializer.Serialize(sw, item);
                        }
                }
            } finally {
                ReleaseWriteLock(cacheFile, fileLock);
            }
        }