Esempio n. 1
0
        public void SetUpFixture()
        {
            MSBuildEngineHelper.InitMSBuildEngine();

            List <LanguageBindingDescriptor> bindings = new List <LanguageBindingDescriptor>();

            using (TextReader reader = RubyBindingAddInFile.ReadAddInFile()) {
                AddIn addin = AddIn.Load(reader, String.Empty);
                bindings.Add(new LanguageBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/LanguageBindings", "Ruby")));
            }
            LanguageBindingService.SetBindings(bindings);

            mockTextEditorProperties = new MockTextEditorProperties();
            convertProjectCommand    = new DerivedConvertProjectToRubyProjectCommand(mockTextEditorProperties);
            parseInfo = new ParseInformation();
            convertProjectCommand.ParseInfo   = parseInfo;
            mockTextEditorProperties.Encoding = Encoding.Unicode;

            sourceProject           = new MockProject();
            sourceProject.Directory = @"d:\projects\test";
            source        = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Program.cs");
            targetProject = (RubyProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
            target        = new FileProjectItem(targetProject, source.ItemType, source.Include);
            source.CopyMetadataTo(target);

            textFileSource = new FileProjectItem(sourceProject, ItemType.None, @"src\readme.txt");
            textFileTarget = new FileProjectItem(targetProject, textFileSource.ItemType, textFileSource.Include);
            textFileSource.CopyMetadataTo(textFileTarget);

            convertProjectCommand.AddParseableFileContent(source.FileName, sourceCode);

            convertProjectCommand.CallConvertFile(source, target);
            convertProjectCommand.CallConvertFile(textFileSource, textFileTarget);
        }
        public void SetUpFixture()
        {
            MSBuildEngineHelper.InitMSBuildEngine();

            List <LanguageBindingDescriptor> bindings = new List <LanguageBindingDescriptor>();

            using (TextReader reader = PythonBindingAddInFile.ReadAddInFile()) {
                AddIn addin = AddIn.Load(reader, String.Empty);
                bindings.Add(new LanguageBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/LanguageBindings", "Python")));
            }
            LanguageBindingService.SetBindings(bindings);

            // Set up IProjectContent so the ConvertProjectToPythonProjectCommand can
            // locate the startup object and determine it's filename.

            mockProjectContent = new MockProjectContent();
            MockClass mainClass = new MockClass(mockProjectContent, startupObject);

            mainClass.CompilationUnit.FileName           = @"d:\projects\test\src\Main2.cs";
            mockProjectContent.ClassToReturnFromGetClass = mainClass;

            mockTextEditorProperties             = new MockTextEditorProperties();
            convertProjectCommand                = new DerivedConvertProjectToPythonProjectCommand(mockTextEditorProperties);
            convertProjectCommand.ProjectContent = mockProjectContent;
            mockTextEditorProperties.Encoding    = Encoding.Unicode;

            Solution solution = new Solution();

            sourceProject          = new MSBuildBasedProject(solution.BuildEngine);
            sourceProject.Parent   = solution;
            sourceProject.FileName = @"d:\projects\test\source.csproj";
            sourceProject.SetProperty(null, null, "StartupObject", startupObject, PropertyStorageLocations.Base, true);
            mainFile      = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Main.cs");
            targetProject = (PythonProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
            convertProjectCommand.CallCopyProperties(sourceProject, targetProject);
            targetMainFile = new FileProjectItem(targetProject, mainFile.ItemType, mainFile.Include);
            mainFile.CopyMetadataTo(targetMainFile);

            main2File       = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Main2.cs");
            targetMain2File = new FileProjectItem(targetProject, main2File.ItemType, main2File.Include);
            main2File.CopyMetadataTo(targetMain2File);

            convertProjectCommand.AddParseableFileContent(mainFile.FileName, mainSource);
            convertProjectCommand.AddParseableFileContent(main2File.FileName, main2Source);

            convertProjectCommand.CallConvertFile(mainFile, targetMainFile);
            convertProjectCommand.CallConvertFile(main2File, targetMain2File);
        }
        public void SetUpFixture()
        {
            MSBuildEngineHelper.InitMSBuildEngine();

            List <LanguageBindingDescriptor> bindings = new List <LanguageBindingDescriptor>();

            using (TextReader reader = PythonBindingAddInFile.ReadAddInFile()) {
                AddIn addin = AddIn.Load(reader, String.Empty);
                bindings.Add(new LanguageBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/LanguageBindings", "Python")));
            }
            LanguageBindingService.SetBindings(bindings);

            mockTextEditorProperties          = new MockTextEditorProperties();
            convertProjectCommand             = new DerivedConvertProjectToPythonProjectCommand(mockTextEditorProperties);
            mockTextEditorProperties.Encoding = Encoding.Unicode;

            sourceProject           = new MockProject();
            sourceProject.Directory = @"d:\projects\test";
            source        = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Program.cs");
            targetProject = (PythonProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject);
            target        = new FileProjectItem(targetProject, source.ItemType, source.Include);
            source.CopyMetadataTo(target);

            textFileSource = new FileProjectItem(sourceProject, ItemType.None, @"src\readme.txt");
            textFileTarget = new FileProjectItem(targetProject, textFileSource.ItemType, textFileSource.Include);
            textFileSource.CopyMetadataTo(textFileTarget);

            foreach (ProjectItem item in targetProject.Items)
            {
                ReferenceProjectItem reference = item as ReferenceProjectItem;
                if ((reference != null) && (reference.Name == "IronPython"))
                {
                    ironPythonReference = reference;
                    break;
                }
            }

            convertProjectCommand.AddParseableFileContent(source.FileName, sourceCode);

            convertProjectCommand.CallConvertFile(source, target);
            convertProjectCommand.CallConvertFile(textFileSource, textFileTarget);
        }
        public static void InitializeLanguageBindings()
        {
            Properties prop = new Properties();

            prop["id"] = "C#";
            prop["supportedextensions"]  = ".cs";
            prop["projectfileextension"] = ".csproj";
            Codon codon1 = new Codon(null, "LanguageBinding", prop, new Condition[0]);

            prop       = new Properties();
            prop["id"] = "VBNet";
            prop["supportedextensions"]  = ".vb";
            prop["projectfileextension"] = ".vbproj";
            Codon codon2 = new Codon(null, "LanguageBinding", prop, new Condition[0]);

            LanguageBindingService.SetBindings(new LanguageBindingDescriptor[] {
                new LanguageBindingDescriptor(codon1),
                new LanguageBindingDescriptor(codon2)
            });
        }