Пример #1
0
        private void StructureParseTypes(CSharpProject project, SDRepository sdRepository)
        {
            var types = project.Compilation.MainAssembly.TopLevelTypeDefinitions.ToList();

            for (int j = 0; j < types.Count; j++)
            {
                var type = types[j];
                if (types[j].Kind != TypeKind.Delegate)
                {
                    PostParseMessage(_parserStrings.ParsingClass + ": " + string.Format("{0}.{1}", types[j].Namespace, types[j].Name));

                    var nameSpace    = sdRepository.GetNamespaceByIdentifier(type.Namespace);
                    var namespaceRef = nameSpace ?? new SDNamespace(type.Namespace)
                    {
                        IsProjectStranger = true
                    };

                    var sdType = new SDType(type.GetIdentifier(), type.Name, namespaceRef)
                    {
                        Accessibility = type.GetDefinition().Accessibility.ToString().ToLower()
                    };

                    sdRepository.AddType(sdType);

                    EventParser.ParseMinimalFields(sdType, types[j]);
                    PropertyParser.ParseMinimalProperties(sdType, types[j]);
                    FieldParser.ParseMinimalFields(sdType, types[j]);
                    MethodParser.ParseMinimalConstructors(sdType, types[j]);
                    MethodParser.ParseMinimalMethods(sdType, types[j]);

                    sdRepository.AddNamespaceTypeRelation(types[j].Namespace, sdType.Identifier);
                }
            }
        }
Пример #2
0
        public ICSharpProject ToProject()
        {
            CSharpProject project;

            if (_settings.IsImage)
            {
                project = new CSharpProject()
                {
                    ModelInputClass,
                    ModelOutputClass,
                    ConsumeModel,
                    ModelProject,
                    NormalizeMapping,
                    ImageLabelMapping,
                };
            }
            else
            {
                project = new CSharpProject()
                {
                    ModelInputClass,
                    ModelOutputClass,
                    ConsumeModel,
                    ModelProject,
                    LabelMapping,
                };
            }
            project.Name = Name;
            return(project);
        }
Пример #3
0
        /// <summary>
        /// Creates the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="references">The references.</param>
        public static void Create(string path, params string[] references)
        {
            var solutionPath = System.IO.Path.Combine(path, @"test.sln");
            var projectPath  = System.IO.Path.Combine(path, "InnerTest.csproj");


            var solution = new Solution(new ProjectChangeWatcher(solutionPath));
            var project  = new CSharpProject(new ProjectCreateInformation
            {
                Solution              = solution,
                SolutionName          = solution.Name,
                ProjectName           = "InnerTest",
                OutputProjectFileName = projectPath
            });
            var provider = (IProjectItemListProvider)project;


            foreach (var reference in references)
            {
                provider.AddProjectItem(new ReferenceProjectItem(project, reference));
            }


            solution.AddFolder(project);
            ParserService.CreateProjectContentForAddedProject(project);
            solution.FixSolutionConfiguration(new IProject[] { project });

            ProjectService.OpenSolution   = solution;
            ProjectService.CurrentProject = project;
        }
Пример #4
0
        public static CSharpReference Parse(XmlNode node)
        {
            CSharpReference ret = new CSharpReference();

            if (node.Name == "PackageReference")
            {
                ret.ReferenceType = CSharpReferenceType.PackageReference;
            }

            if (node.Name == "ProjectReference")
            {
                ret.ReferenceType = CSharpReferenceType.ProjectReference;
            }

            if (node.Name == "EmbeddedResource")
            {
                ret.ReferenceType = CSharpReferenceType.EmbeddedResource;
            }

            ret.internalAttributes = new List <SerializableKeyValuePair <string, string> >();
            List <XmlAttribute> attribs = CSharpProject.GetAttributes(node);

            foreach (XmlAttribute xmlAttribute in attribs)
            {
                ret.internalAttributes.Add(
                    new SerializableKeyValuePair <string, string>
                {
                    Key   = xmlAttribute.Name,
                    Value = xmlAttribute.Value
                }
                    );
            }

            return(ret);
        }
Пример #5
0
 public void GeneratePocos(CDBM db, CSharpProject p, CUsing NamespaceName, TextWriter mensajes)
 {
     foreach (CTableM t in db.lTable)
     {
         p.AddCSharpFile(PocoName(t.Name), NamespaceName);
         CClass c = p.AddClass(PocoName(t.Name));
         c.lUsing.Add(CSharpStandarUsing.System);
         CConstructor consVacio = new CConstructor(c, CSharpVisibility.cvPublic);
         CConstructor cons      = new CConstructor(c, CSharpVisibility.cvPublic);
         //Se añaden al final por estética de la clase generada
         foreach (CFieldM f in t.lFieldAll)
         {
             CType aux = CGenerator.SqlServerTD2CSharp(f.Td, f.IsNullable);
             if (aux.Equals(CSharpPrimitiveType.cDateTime))
             {
                 c.lUsing.Add(CSharpStandarUsing.System);
             }
             c.AddField(new CField(f.Name, aux, CSharpVisibility.cvPublic));
             cons.AddParam(SUtil.LowerFirst(f.Name), CGenerator.SqlServerTD2CSharp(f.Td, f.IsNullable));
             cons.AddSentence(new CTextualSentence($"this.{f.Name} = {SUtil.LowerFirst(f.Name)};"));
         }
         c.AddConstructor(consVacio);
         c.AddConstructor(cons);
     }
     mensajes.WriteLine("Pocos generados en: " + p.RootDirectory.ActualDirectory.FullName);
 }
Пример #6
0
        public override void GenerateCSharpProject(CSharpProject project, string assemblyName, IEnumerable <string> sourceFiles, IEnumerable <string> defines, IEnumerable <CSharpProject> additionalProjectReferences)
        {
            MetroAssemblyCSharpCreator.AssemblyCSharpPlugin plugin;
            string[] strArray2;
            string[] strArray3;
            WSASDK   wsaSDK = EditorUserBuildSettings.wsaSDK;

            if (wsaSDK == WSASDK.UniversalSDK81)
            {
                wsaSDK = WSASDK.SDK81;
            }
            string playbackEngineDirectory = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.WSAPlayer, BuildOptions.CompressTextures);

            if (additionalProjectReferences != null)
            {
                string directoryName = Path.GetDirectoryName(project.Path);
                foreach (CSharpProject project2 in additionalProjectReferences)
                {
                    string strB = Path.GetDirectoryName(project2.Path);
                    if (string.Compare(directoryName, strB, true) == 0)
                    {
                        throw new Exception($"Projects {directoryName} and {strB} should be in different folders.");
                    }
                }
            }
            List <MetroAssemblyCSharpCreator.AssemblyCSharpPlugin> plugins = new List <MetroAssemblyCSharpCreator.AssemblyCSharpPlugin>();

            string[] strArray = new string[] { ".dll", ".winmd" };
            string   fullPath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));

            foreach (PluginImporter importer in PluginImporter.GetImporters(BuildTarget.WSAPlayer))
            {
Пример #7
0
        public void Generate(Builder builder, CSharpProject project, List <Project.Configuration> configurations, string projectPath, IList <string> generatedFiles, IList <string> skipFiles)
        {
            var configuration  = configurations[0];
            var frameworkFlags = project.Targets.TargetPossibilities.Select(f => f.GetFragment <DotNetFramework>()).Aggregate((x, y) => x | y);
            var frameworks     = ((DotNetFramework[])Enum.GetValues(typeof(DotNetFramework))).Where(f => frameworkFlags.HasFlag(f)).Select(f => f.ToFolderName());

            Generate(builder, configuration, frameworks, projectPath, generatedFiles, skipFiles);
        }
Пример #8
0
 public UnresolvedCSharpProjectReference(CSharpProject project, LfdErrorReporter errors, LfdLine line)
 {
     this.project = project;
     this.errors  = errors;
     this.line    = line;
     errors.EnforceFieldCount(line, 1);
     this.referenceName = line.fields[0];
 }
Пример #9
0
        private void ParseTypes(CSharpProject project, SDRepository sdRepository, ICoreConfigSection sharpDoxConfig)
        {
            var typeParser = new TypeParser(sdRepository, sharpDoxConfig);

            typeParser.OnItemParseStart += (n) => { PostParseMessage(_parserStrings.ParsingClass + ": " + n); };

            typeParser.ParseProjectTypes(project);
        }
Пример #10
0
        private void ParseNamespaces(CSharpProject project, SDRepository sdRepository, ICoreConfigSection sharpDoxConfig, Dictionary <string, string> tokens)
        {
            var namespaceParser = new NamespaceParser(sdRepository, sharpDoxConfig, sharpDoxConfig.InputFile, tokens);

            namespaceParser.OnDocLanguageFound += ExecuteOnDocLanguageFound;
            namespaceParser.OnItemParseStart   += (n) => { PostParseMessage(_parserStrings.ParsingNamespace + ": " + n); };

            namespaceParser.ParseProjectNamespaces(project);
        }
Пример #11
0
    // Assumption: filename already exists and is already verified to be a file
    public static void LoadFile(MetabuildProject metabuild, String filename)
    {
        Console.WriteLine("[DEBUG] Metabuild.LoadFile \"{0}\"", filename);
        String relativeDir = null;

        using (LfdTextReader reader = new LfdTextReader(new StreamReader(new FileStream(
                                                                             filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))))
        {
            LfdParser parser = new LfdParser(reader, filename);
            LfdLine   line   = parser.reader.ReadLineIgnoreComments();
            for (; ;)
            {
                if (line == null)
                {
                    return;
                }

                if (line.id == "Import")
                {
                    parser.errors.EnforceFieldCount(line, 1);
                    MetabuildUnit.LoadDirOrFile(metabuild, line.fields[0]);
                    line = parser.reader.ReadLineIgnoreComments();
                }
                else if (line.id == "CSharpProject")
                {
                    if (relativeDir == null)
                    {
                        relativeDir = Path.GetDirectoryName(filename);
                    }
                    line = CSharpProject.Parse(metabuild, parser, line, false, relativeDir);
                }
                else if (line.id == "CSharpTestProject")
                {
                    if (relativeDir == null)
                    {
                        relativeDir = Path.GetDirectoryName(filename);
                    }
                    line = CSharpProject.Parse(metabuild, parser, line, true, relativeDir);
                }
                else if (line.id == "GeneratePathPrefix")
                {
                    parser.errors.EnforceFieldCount(line, 1);
                    if (metabuild.generatePathPrefix != null)
                    {
                        throw parser.errors.Error(line, "GeneratePathPrefix was set more than once");
                    }
                    metabuild.generatePathPrefix = line.fields[0];
                    line = parser.reader.ReadLineIgnoreComments();
                }
                else
                {
                    throw parser.errors.Error(line, "unknown directive '{0}'", line.id);
                }
            }
        }
    }
        public override bool Supports(Version version)
        {
            CSharpProject project = resolver.TypeResolveContext.Compilation.GetProject() as CSharpProject;

            if (project == null)
            {
                return(false);
            }
            return(project.LanguageVersion >= version);
        }
Пример #13
0
        public void WatchProjectFolders(IEnumerable <string> folders)
        {
            DisposeWatchers();

            mapFolderToProject = folders.ToDictionary(k => k, v => CSharpProject.GetSingleProjectFromFolder(v));

            watchers = folders.Select(p => new FSWatcher(_logStream, p)).ToList();
            watchers.ForEach(w => w.Subscribe(e => _fsStream.OnNext(e)));

            StreamInitialContent(folders);
        }
Пример #14
0
 public void Visit(CSharpProject project)
 {
     if (project.IsTestProject && wince)
     {
         Console.WriteLine("[WARNING] generating wince test projects not implemented");
         return;
     }
     writer.WriteLine("Project(\"{{{0}}}\") = \"{1}\", \"{1}{2}.csproj\", \"{{{3}}}\"",
                      solutionGuid.ToString().ToUpper(), project.Name, wince ? ".CE" : "", project.ProjectGuid);
     writer.WriteLine("EndProject");
 }
Пример #15
0
        void StreamInitialContent(IEnumerable <string> folders)
        {
            folders.ForEach(folder =>
            {
                var allFiles = new List <string>();

                CSharpProject.CollectFiles(folder, allFiles);

                allFiles.ForEach(file => _fsStream.OnNext(new FSChange(folder, file)));
            });
        }
Пример #16
0
 public void Visit(CSharpProject project)
 {
     if (project.IsTestProject && wince)
     {
         Console.WriteLine("[WARNING] generating wince test projects not implemented");
         return;
     }
     writer.WriteLine("\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU", project.ProjectGuid.ToString().ToUpper());
     writer.WriteLine("\t\t{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU", project.ProjectGuid.ToString().ToUpper());
     writer.WriteLine("\t\t{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU", project.ProjectGuid.ToString().ToUpper());
     writer.WriteLine("\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU", project.ProjectGuid.ToString().ToUpper());
 }
Пример #17
0
        private void StructureParseNamespaces(CSharpProject project, SDRepository sdRepository)
        {
            var types = project.Compilation.MainAssembly.TopLevelTypeDefinitions.ToList();

            for (int j = 0; j < types.Count; j++)
            {
                PostParseMessage(_parserStrings.ParsingNamespace + ": " + types[j].Namespace);

                var sdNamespace = new SDNamespace(types[j].Namespace);
                sdRepository.AddNamespace(sdNamespace);
            }
        }
        public ICSharpProject ToProject()
        {
            var project = new CSharpProject()
            {
                ModelBuilder,
                PredictProject,
                PredictProgram,
            };

            project.Name = Name;
            return(project);
        }
Пример #19
0
        public void Generate(Builder builder, CSharpProject project, List <Project.Configuration> configurations, string projectPath, List <string> generatedFiles, List <string> skipFiles)
        {
            _builder     = builder;
            _projectPath = projectPath;

            var configuration  = configurations[0];
            var frameworkFlags = project.Targets.TargetPossibilities.Select(f => f.GetFragment <DotNetFramework>()).Aggregate((x, y) => x | y);

            GenerateProjectJson(configuration, frameworkFlags, generatedFiles, skipFiles);

            _builder = null;
        }
Пример #20
0
        internal void ParseProjectNamespaces(CSharpProject project)
        {
            var types = project.Compilation.MainAssembly.TopLevelTypeDefinitions.ToList();

            for (int i = 0; i < types.Count; i++)
            {
                HandleOnItemParseStart(types[i].Namespace, i, types.Count);
                if (!_excludedIdentifiers.Contains(types[i].Namespace))
                {
                    _repository.AddNamespace(GetParsedNamespace(types[i]));
                }
            }
        }
Пример #21
0
        protected override IProject CreateTestProject()
        {
            ProjectCreateInformation info = new ProjectCreateInformation();

            info.ProjectName           = "Test";
            info.RootNamespace         = "Test";
            info.OutputProjectFileName = Path.Combine(Path.GetTempPath(), "Test.csproj");
            info.Solution = this.Solution;

            CSharpProject p = new CSharpProject(info);

            return(p);
        }
Пример #22
0
        public void TransfromDirectory(string projectDirectory)
        {
            using (var scope = _containerFactory.CreateScope())
            {
                var logStream             = scope.Resolve <ILogStream>();
                var projectTransformation = scope.Resolve <IQuokkaProjectTransformation>();

                var config            = QuokkaConfigLoader.Load(projectDirectory);
                var projectPath       = CSharpProject.GetSingleProjectFromFolder(projectDirectory);
                var projectReferences = CSharpProject.RecursiveCollectProjectReferences(projectPath);
                var projectFolders    = projectReferences.Select(p => Path.GetDirectoryName(p));

                var codeFiles = projectFolders.Select(folder =>
                {
                    var allFiles = new List <string>();
                    CSharpProject.CollectFiles(folder, allFiles);

                    return(allFiles.Select(f =>
                    {
                        var content = "";
                        FileTools.TryReadAllText(f, out content);

                        return new SourceFileSnapshot()
                        {
                            ProjectName = CSharpProject.GetSingleProjectFromFolder(folder),
                            FullPath = f,
                            Content = content
                        };
                    }));
                }).SelectMany(s => s);


                var transformedCode = new SourceCodeSnapshot(
                    projectTransformation.Transform(
                        new TransformationRequest()
                {
                    Sources        = codeFiles.ToList(),
                    Configurations = config.Configurations
                }).Result.Result);

                new QuartusProjectTools(logStream).SaveCodeSnapshot(
                    transformedCode,
                    config.Project,
                    config.ProjectLocation,
                    config.Configurations.Select(c => c.Name).ToHashSet());
            }
        }
Пример #23
0
        internal void ParseProjectTypes(CSharpProject project)
        {
            var types = project.Compilation.MainAssembly.TopLevelTypeDefinitions.ToList();

            for (int i = 0; i < types.Count; i++)
            {
                if (types[i].Kind != TypeKind.Delegate)
                {
                    HandleOnItemParseStart(string.Format("{0}.{1}", types[i].Namespace, types[i].Name));
                    if (!IsMemberExcluded(types[i].GetIdentifier(), types[i].Accessibility.ToString()))
                    {
                        var sdType = GetParsedType(types[i].GetDefinition(), false);
                        _repository.AddNamespaceTypeRelation(types[i].Namespace, sdType.Identifier);
                    }
                }
            }
        }
Пример #24
0
        private AmmyProject GetAmmyProject(string filename, out string projectName)
        {
            AmmyProject cachedProject;

            var genericProject = DteHelpers.GetProjectByFilename(filename);

            if (genericProject == null || genericProject.Kind == EnvDTE.Constants.vsProjectKindMisc)
            {
                throw new CompilerServiceException("Project not found for file: " + filename);
            }

            projectName = genericProject.Name;

            if (_projectCaches.TryGetValue(projectName, out cachedProject))
            {
                var cachedReferences = cachedProject.References.Select(r => r.Path).ToList();
                var cachedFiles      = GetCachedFiles(cachedProject);

                var newProject = new AmmyProject(cachedReferences, cachedFiles, cachedProject.CSharpProject, cachedProject.FsProject.Data, cachedProject.FsProject.ProjectDir, cachedProject.OutputPath, cachedProject.RootNamespace, cachedProject.AssemblyName, cachedProject.TargetPath);
                return(newProject);
            }

            var projectItems    = DteHelpers.GetFileList(genericProject);
            var ammyFileMetas   = GetAmmyFileMetas(projectItems);
            var sourceFilenames = projectItems.Select(pi => DteHelpers.GetFilename(pi)).ToArray();
            var project         = (VSProject)genericProject.Object;
            var fullPath        = genericProject.Properties.Item("FullPath").Value.ToString();
            var objRelativePath = genericProject.ConfigurationManager.ActiveConfiguration.Properties.Item("IntermediatePath").Value.ToString();
            var outputPath      = genericProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
            var outputFileName  = genericProject.Properties.Item("OutputFileName").Value.ToString();
            var targetPath      = Path.Combine(fullPath, outputPath, outputFileName);
            var rootNamespace   = genericProject.Properties.Item("RootNamespace").Value.ToString();
            var assemblyName    = genericProject.Properties.Item("AssemblyName").Value.ToString();
            //var hostAssemblyPath = Path.Combine(outputDir, outputFileName);
            var references      = GetReferences(project);
            var compilationData = NeedReferenceRefresh(references) ? null : LatestResult?.CompilationData;
            var csharpProject   = new CSharpProject(fullPath, sourceFilenames);
            var ammyProject     = new AmmyProject(references, ammyFileMetas, csharpProject, compilationData, fullPath, objRelativePath, rootNamespace, assemblyName, targetPath);

            _projectCaches[projectName] = ammyProject;
            SubscribeToReferenceChanges(project, projectName);

            return(ammyProject);
        }
Пример #25
0
        public void GenerateProject(CDBM db, string dir, string NamespaceName, string projectName, TextWriter mensajes)
        {
            CSharpProject p         = new CSharpProject(projectName, dir);
            CDirectory    baseDir   = p.ActualDirectory;
            CUsing        Namespace = new CUsing(NamespaceName);

            GenerateDef(db, p, NamespaceName, mensajes);
            p.AddChildDirectory(baseDir, "Poco");
            CUsing NamespacePocos = new CUsing(NamespaceName + ".Poco");

            GeneratePocos(db, p, NamespacePocos, mensajes);
            p.AddChildDirectory(baseDir, "Dao");
            GenerateDaos(db, p, NamespaceName + ".Dao", NamespacePocos, mensajes);
            CUsing NamespaceDao = new CUsing(NamespaceName + ".Dao");

            p.AddChildDirectory(baseDir, "Bo");
            GenerateBo(db, p, NamespaceName + ".Bo", NamespacePocos, NamespaceDao, mensajes);
            p.Generate(mensajes);
        }
Пример #26
0
 public Boolean Resolve(MetabuildProject metabuild)
 {
     foreach (MetabuildUnit unit in metabuild.units)
     {
         CSharpProject unitAsCSharpProject = unit as CSharpProject;
         if (unitAsCSharpProject != null && unitAsCSharpProject.Name == referenceName)
         {
             if (project.projectReferenceList.Contains(unitAsCSharpProject))
             {
                 errors.PrintError(line, "project {0} was referenced multiple times", referenceName);
                 return(false); // fail
             }
             project.projectReferenceList.Add(unitAsCSharpProject);
             return(true); // success
         }
     }
     errors.PrintError(line, "unknown project reference {0}", referenceName);
     return(false); // fail
 }
Пример #27
0
        void EventHandler(IEnumerable <FSEvent> list)
        {
            var projectFiles = list.Where(e => Path.GetExtension(e.FullPath) == CSharpProject.CSharpProjectExtension);

            if (projectFiles.Any())
            {
                DisposeWatchers();

                var projectReferences = CSharpProject.RecursiveCollectProjectReferences(ProjectPath);
                var projectFolders    = projectReferences.Select(r => Path.GetDirectoryName(r));

                watchers = projectFolders.Select(p => new FSWatcher(_logStream, p)).ToList();
                watchers.ForEach(w => w.Subscribe(e => _fsStream.OnNext(e)));

                _logStream.WriteLine(eContentDomain.Public, "Projects were changed");

                _stream.OnNext(new ProjectFoldersSnapshot(projectFolders));
            }
        }
Пример #28
0
        public CSharpFile BuildCSharpFile(CSharpProject p, FilePath filename)
        {
            if (_openDocumentManager.IsDocumentOpen(filename))
            {
                _log.DebugFormat("Class file is open and will not be cached: [{0}]", filename);

                return(new CSharpFile(p, filename, _fileReader.ReadAllText(filename)));
            }

            return(_fileCache.GetOrAdd(filename,
                                       f =>
            {
                _log.DebugFormat("Build CSharpFile [{0}]", filename);

                _fileByProjectIndex.Add(p.FileName, f);

                return new CSharpFile(p, f, _fileReader.ReadAllText(f));
            }));
        }
Пример #29
0
        public ICSharpProject ToProject()
        {
            CSharpProject project;

            if (_settings.IsImage)
            {
                project = new CSharpProject()
                {
                    ModelInputClass,
                    ModelOutputClass,
                    ConsumeModel,
                    ModelProject,
                    NormalizeMapping,
                    ImageLabelMapping,
                };
            }
            else if (_settings.IsObjectDetection)
            {
                project = new CSharpProject()
                {
                    ModelInputClass,
                    ModelOutputClass,
                    ObjectDetectionConsumeModel,
                    ModelProject,
                    ReshapeTransformerMap,
                    ObjectDetectionLabelMapping,
                };
            }
            else
            {
                project = new CSharpProject()
                {
                    ModelInputClass,
                    ModelOutputClass,
                    ConsumeModel,
                    ModelProject,
                    LabelMapping,
                };
            }
            project.Name = Name;
            return(project);
        }
Пример #30
0
 public static string Display(this CSharpProject project, StringBuilder output)
 {
     if (output == null)
     {
         output = new StringBuilder();
     }
     if (project == null)
     {
         output.Append("<null>");
     }
     else
     {
         output.AppendLine("> " + project.Path);
         //foreach (Reference reference in project.References)
         //{
         //    Display(reference, output);
         //}
     }
     return(output.ToString());
 }