private void CreateProjectConfigurationPlatforms(VisualStudioSolution solution, Guid projectId)
        {
            var solutionConfigurationPlatforms = solution.Global.Sections.FirstOrDefault(x => x.Name.Equals("SolutionConfigurationPlatforms"));

            if (solutionConfigurationPlatforms == null)
            {
                return;
            }

            var projectConfigurationPlatforms = solution.Global.Sections.FirstOrDefault(x => x.Name.Equals("ProjectConfigurationPlatforms"));

            if (projectConfigurationPlatforms == null)
            {
                var index = solution.Global.Sections.IndexOf(solutionConfigurationPlatforms);

                projectConfigurationPlatforms = new GlobalSection
                {
                    Name        = "ProjectConfigurationPlatforms",
                    SectionType = "postSolution"
                };

                solution.Global.Sections.Insert(index + 1, projectConfigurationPlatforms);
            }

            projectConfigurationPlatforms.Items.AddRange(
                solutionConfigurationPlatforms.Items.Select(x => new GlobalSectionItem
            {
                Name  = $"{projectId.ToString("B").ToUpperInvariant()}.{x.Name}",
                Value = x.Value
            }
                                                            ));
        }
예제 #2
0
 private void RenderGlobalSection(GlobalSection globalSection, StringWriter sb)
 {
     sb.WriteLine("\tGlobalSection({0}) = {1}", globalSection.Name, Render(globalSection.Type));
     foreach (var entry in globalSection.Entries)
     {
         sb.WriteLine("\t\t{0} = {1}", entry.Key, entry.Value);
     }
     sb.WriteLine("\tEndGlobalSection");
 }
 private void WriteGlobalSection(StringBuilder sb, GlobalSection section)
 {
     sb.AppendLine($"\tGlobalSection({section.Name}) = {section.SectionType}");
     foreach (var item in section.Items)
     {
         sb.AppendLine($"\t\t{item.Name} = {item.Value}");
     }
     sb.AppendLine("\tEndGlobalSection");
 }
예제 #4
0
 public ConfigurationMgr()
 {
     _global                = new GlobalSection();
     _manxcat               = new ManxcatSection();
     _pairwise              = new PairwiseSection();
     _smithWaterman         = new SmithWatermanSection();
     _needlemanWunsch       = new NeedlemanWunschSection();
     _smithWatermanMS       = new SmithWatermanMS();
     _daVectorSpongeSection = new DAVectorSpongeSection();
 }
예제 #5
0
        private static async Task _WriteGlobalSection(TextWriter writer, GlobalSection section)
        {
            await writer.WriteLineAsync($"\tGlobalSection({section.Name}) = {_Format(section.Type)}");

            foreach (var entry in section.Entries)
            {
                await writer.WriteLineAsync($"\t\t{entry.Key} = {entry.Value}");
            }

            await writer.WriteLineAsync("\tEndGlobalSection");
        }
예제 #6
0
        private void CreateProjectConfiguration(GlobalSection projectionConfigurations, SolutionProject project)
        {
            foreach (var info in projectionConfigurations.Info)
            {
                if (!info.Key.StartsWith(project.Id))
                    continue;

                var config = info.Key.Replace(project.Id + ".", "");

                project.AddConfiguration(projectionConfigurations.Name, projectionConfigurations.When, config, info.Value);
            }
        }
예제 #7
0
        /// <summary>
        /// Closes the inifile and writes all changes to it.
        /// </summary>
        public void Close()
        {
            var builder = new StringBuilder();

            builder.Append(GlobalSection.ToString());

            foreach (var section in sections.Values)
            {
                builder.Append(sections.ToString());
            }

            File.WriteAllText(FileName, builder.ToString());
        }
예제 #8
0
        private void CreateProjectConfiguration(GlobalSection projectionConfigurations, SolutionProject project)
        {
            foreach (var info in projectionConfigurations.Info)
            {
                if (!info.Key.StartsWith(project.Id))
                {
                    continue;
                }

                var config = info.Key.Replace(project.Id + ".", "");

                project.AddConfiguration(projectionConfigurations.Name, projectionConfigurations.When, config, info.Value);
            }
        }
예제 #9
0
        /// <summary>
        /// Reads the non-custom section with the given header.
        /// </summary>
        /// <param name="Header">The section header.</param>
        /// <returns>The parsed section.</returns>
        protected Section ReadKnownSectionPayload(SectionHeader Header)
        {
            switch (Header.Name.Code)
            {
            case SectionCode.Type:
                return(TypeSection.ReadSectionPayload(Header, this));

            case SectionCode.Import:
                return(ImportSection.ReadSectionPayload(Header, this));

            case SectionCode.Function:
                return(FunctionSection.ReadSectionPayload(Header, this));

            case SectionCode.Table:
                return(TableSection.ReadSectionPayload(Header, this));

            case SectionCode.Memory:
                return(MemorySection.ReadSectionPayload(Header, this));

            case SectionCode.Global:
                return(GlobalSection.ReadSectionPayload(Header, this));

            case SectionCode.Export:
                return(ExportSection.ReadSectionPayload(Header, this));

            case SectionCode.Start:
                return(StartSection.ReadSectionPayload(Header, this));

            case SectionCode.Element:
                return(ElementSection.ReadSectionPayload(Header, this));

            case SectionCode.Code:
                return(CodeSection.ReadSectionPayload(Header, this));

            case SectionCode.Data:
                return(DataSection.ReadSectionPayload(Header, this));

            default:
                return(ReadUnknownSectionPayload(Header));
            }
        }
예제 #10
0
        public static void Main(string[] args)
        {
            ISolution     solution;
            GlobalSection postSolution, preSolution;

            if (File.Exists("/Users/dean/Projects/Foo2/Foo2.sln"))
            {
                solution     = SolutionParser.Parse("/Users/dean/Projects/Foo2/Foo2.sln");
                preSolution  = solution.Global.FirstOrDefault(x => x.Type == GlobalSectionType.PreSolution);
                postSolution = solution.Global.FirstOrDefault(x => x.Type == GlobalSectionType.PostSolution);
            }
            else
            {
                solution = new Solution();
                solution.Header.Add("Microsoft Visual Studio Solution File, Format Version 12.00");
                solution.Header.Add("# Visual Studio 2012");
                preSolution = new GlobalSection("SolutionConfigurationPlatforms", GlobalSectionType.PreSolution);
                preSolution.Entries.Add("Debug|AnyCPU", "Debug|AnyCPU");
                preSolution.Entries.Add("Release|AnyCPU", "Release|AnyCPU");
                solution.Global.Add(preSolution);
                postSolution = new GlobalSection("ProjectConfigurationPlatforms", GlobalSectionType.PostSolution);
                solution.Global.Add(preSolution);
            }

            if (!solution.Projects.Any((arg) => arg.Name == "Test.UWP"))
            {
                var guid = Guid.NewGuid();
                solution.Projects.Add(new Project(Guid.Parse("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"), "Test.UWP", "Test.UWP\\Test.UWP.csproj", guid)
                {
                });
                postSolution.Entries.Add($"{guid}.Debug|AnyCPU.ActiveCfg", "Debug");
                postSolution.Entries.Add($"{guid}.Debug|AnyCPU.Build.0", "Debug");
                postSolution.Entries.Add($"{guid}.Release|AnyCPU.ActiveCfg", "Release");
                postSolution.Entries.Add($"{guid}.Release|AnyCPU.Build.0", "Release");
            }

            var renderer = new SolutionRenderer(solution);

            Console.WriteLine(renderer.Render());
        }
예제 #11
0
            public static Global TryParse(string[] lines, ref int index)
            {
                if (lines[index] != "Global")
                {
                    return(null);
                }
                var global = new Global();

                for (index++; index < lines.Length; index++)
                {
                    if (lines[index] == "EndGlobal")
                    {
                        break;
                    }
                    var section = GlobalSection.TryParse(lines, ref index);
                    if (section == null)
                    {
                        continue;
                    }
                    global.Sections.Add(section);
                }
                return(global);
            }
        private void ParseGlobalSection(VisualStudioSolution solution, string sectionline)
        {
            var matches = Regex.Match(sectionline, SolutionConstants.GlobalSectionRegEx);

            var section = new GlobalSection
            {
                Name        = matches.Groups["sectionName"].Value,
                SectionType = matches.Groups["sectionValue"].Value
            };

            solution.Global.Sections.Add(section);

            string str;

            while ((str = ReadLine()) != null)
            {
                if (str.Equals("EndGlobalSection"))
                {
                    return;
                }

                section.Items.Add(ParseGlobalSectionItem(str));
            }
        }
 public void SetUp()
 {
     theSection = new GlobalSection("    GlobalSection(SolutionProperties) = preSolution");
 }
예제 #14
0
 public void SetUp()
 {
     theSection = new GlobalSection("    GlobalSection(SolutionProperties) = preSolution");
 }
예제 #15
0
        // strict parse means all sections must come in order
        public void ParseAsWASM(string filename, bool strict_parse = true)
        {
            if (!BitConverter.IsLittleEndian)
            {
                throw new NotImplementedException("LEB128 implementation only handles little endian systems");
            }

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                BinaryReader reader = new BinaryReader(fs);
                uint         magic  = reader.ReadUInt32();
                if (magic != MAGIC)
                {
                    throw new Exception("Not a compiled Web Assembly file.");
                }

                uint version = reader.ReadUInt32();
                if (version > SUPPORTED_VERSION)
                {
                    throw new Exception($"Unsupported version. Expected version <= {SUPPORTED_VERSION}, received {version}.");
                }

                int last_parsed_module = int.MinValue;

                /* Read in each module */

                while (true)
                {
                    int id = reader.PeekChar();

                    // EOF
                    if (id == -1)
                    {
                        break;
                    }

                    if (strict_parse && id < last_parsed_module)
                    {
                        throw new Exception("File contains out of order sections.");
                    }
                    last_parsed_module = id;

                    switch (id)
                    {
                    case (int)WebAssemblyModuleID.Custom:
                        if (strict_parse && custom != null)
                        {
                            throw new Exception("File contains a duplicate custom section.");
                        }
                        custom = new CustomSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Type:
                        if (strict_parse && type != null)
                        {
                            throw new Exception("File contains a duplicate type section.");
                        }
                        type = new TypeSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Import:
                        if (strict_parse && import != null)
                        {
                            throw new Exception("File contains a duplicate import section.");
                        }
                        import = new ImportSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Function:
                        if (strict_parse && function != null)
                        {
                            throw new Exception("File contains a duplicate function section.");
                        }
                        function = new FunctionSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Table:
                        if (strict_parse && table != null)
                        {
                            throw new Exception("File contains a duplicate table section.");
                        }
                        table = new TableSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Memory:
                        if (strict_parse && memory != null)
                        {
                            throw new Exception("File contains a duplicate memory section.");
                        }
                        memory = new MemorySection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Global:
                        if (strict_parse && global != null)
                        {
                            throw new Exception("File contains a duplicate global section.");
                        }
                        global = new GlobalSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Export:
                        if (strict_parse && export != null)
                        {
                            throw new Exception("File contains a duplicate export section.");
                        }
                        export = new ExportSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Start:
                        if (strict_parse && start != null)
                        {
                            throw new Exception("File contains a duplicate start section.");
                        }
                        start = new StartSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Element:
                        if (strict_parse && element != null)
                        {
                            throw new Exception("File contains a duplicate element section.");
                        }
                        element = new ElementSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Code:
                        if (strict_parse && code != null)
                        {
                            throw new Exception("File contains a duplicate code section.");
                        }
                        code = new CodeSection(reader);
                        break;

                    case (int)WebAssemblyModuleID.Data:
                        if (strict_parse && data != null)
                        {
                            throw new Exception("File contains a duplicate data section.");
                        }
                        data = new DataSection(reader);
                        break;

                    // Error
                    default:
                        throw new Exception($"Unknown section {id}.");
                    }
                }

                /* Additional validation */

                // The lengths of vectors produced by the (possibly empty) function and code section must match up.
                if ((function != null && code == null) || (function == null && code != null))
                {
                    throw new Exception("File corrupt. Must include both function and code sections.");
                }
                if (function.types.Length != code.bodies.Length)
                {
                    throw new Exception("File corrupt. Function and code sections do not match up.");
                }

                // TODO: I don't actually check if data overlaps

                // TODO: Validate everything in this list
                // https://webassembly.github.io/spec/core/valid/modules.html
            }
        }
예제 #16
0
        private static GlobalSection GetGlobalSection(LexicalAnalizer lexan)
        {
            GlobalSection gs = new GlobalSection();

            lexan.Expect(Semantics.GLOBAL_SECTION);
            lexan.MoveNext();

            lexan.Expect(Semantics.OPEN_PARENTHESIS);
            lexan.MoveNext();

            lexan.Expect(Semantics.STRING_VALUE);
            gs.Name = lexan.Current.Value;
            lexan.MoveNext();

            lexan.Expect(Semantics.CLOSE_PARENTHESIS);
            lexan.MoveNext();

            lexan.Expect(Semantics.EQUALS);
            lexan.MoveNext();

            lexan.Expect(Semantics.STRING_VALUE);
            gs.Value = lexan.Current.Value;
            lexan.MoveNext();

            lexan.Expect(Semantics.EOL);



            while (lexan.MoveNext())
            {
                switch (lexan.Current.Token)
                {
                case Semantics.END_GLOBAL_SECTION:
                    return(gs);

                case Semantics.STRING_VALUE:
                {
                    lexan.Expect(Semantics.STRING_VALUE);
                    string key = lexan.Current.Value;
                    lexan.MoveNext();

                    lexan.Expect(Semantics.EQUALS);
                    lexan.MoveNext();

                    lexan.ExpectQuotedOrString();
                    string value = lexan.Current.Value;
                    gs.Map.Add(key.Trim(' ', '\n', '\t'), value);
                    lexan.MoveNext();

                    lexan.Expect(Semantics.EOL);
                }
                break;

                case Semantics.QUOTED_STRING:
                {
                    lexan.Expect(Semantics.QUOTED_STRING);
                    string key = lexan.Current.Value;
                    lexan.MoveNext();

                    lexan.Expect(Semantics.EQUALS);
                    lexan.MoveNext();

                    lexan.ExpectQuotedOrString();
                    string value = lexan.Current.Value;
                    gs.Map.Add(key.Trim(' ', '\n', '\t'), value);
                    lexan.MoveNext();

                    lexan.Expect(Semantics.EOL);
                }
                break;

                case Semantics.EOL:
                    break;

                default:
                    throw new Exception("Invalid GlobalSection Entry!");
                }
            }


            throw new Exception("Expecting EndGlobalSection!");
        }