public void TestAssemblyMappingSQLConnectorGetAllOldDllPathsTest() { var nsMap = NSMappingSQLConnector.GetInstance().GetOrCreateOldNSMap(id, "A"); AssertAditional.SetEquals(new HashSet <string> { }, instance.GetAllOldDllPaths(id), "initial value"); var mapA = instance.GetOrCreateOldAssemblyMap(id, "path"); var mapB = instance.GetOrCreateOldAssemblyMap(id, "path"); AssertAditional.SetEquals(new HashSet <string> { "path" }, instance.GetAllOldDllPaths(id), "added entry"); instance.GetOrCreateOldAssemblyMap(id, "path2"); AssertAditional.SetEquals(new HashSet <string> { "path", "path2" }, instance.GetAllOldDllPaths(id), "added second entry"); SDKMappingSQLConnector.GetInstance().SaveOldSDKMapping(id, "A", "A", nsMap, mapA); var targetA = SDKMappingSQLConnector.GetInstance().GetSDKMappingByIdentifiers(id, "A"); SDKMappingSQLConnector.GetInstance().SaveOldSDKMapping(id, "B", "B", nsMap, mapA); var targetB = SDKMappingSQLConnector.GetInstance().GetSDKMappingByIdentifiers(id, "B"); instance.UpdateAssemblyMapping(mapA, targetA, "pathNew", "name"); instance.UpdateAssemblyMapping(mapB, targetB, "pathNew2", "name2"); SDKMappingSQLConnector.GetInstance().UpdateSDKMapping(targetA, "A"); SDKMappingSQLConnector.GetInstance().UpdateSDKMapping(targetA, "B"); AssertAditional.SetEquals(new HashSet <string> { "path", "path2" }, instance.GetAllOldDllPaths(id), "double count of first entry"); }
public void ProcessProject(string[] args) { Helper.verifyFileExists(args[0]); var filePath = args[0]; if (filePath.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || filePath.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase)) { // put all changes in new project folder // create copies of the project so don't have to overwrite the original files string projectParentFolder = new FileInfo(filePath).DirectoryName; string transformed_folder = projectParentFolder + "_transformed"; Console.WriteLine("Copying project directory"); Console.WriteLine("Removing the old transformed directory before copying contents"); CopyDirectory(transformed_folder, projectParentFolder); Console.WriteLine("Begin transforming files"); // Proccess the project here Project proj = MSBuildWorkspace.Create().OpenProjectAsync(filePath).Result; HashSet <String> namespaceSet = nsMappingConnector.GetAllNamespaces(sdkId); Dictionary <String, HashSet <String> > namespaceToClassnameSetMap = new Dictionary <string, HashSet <string> >(); foreach (Document doc in proj.Documents) { var semanticModel = doc.GetSemanticModelAsync().Result; var syntaxTree = doc.GetSyntaxTreeAsync().Result; // do processing here var documentEditor = DocumentEditor.CreateAsync(doc).Result; if (IsDocCSharp(doc)) { TransformFileCSharp ft = new TransformFileCSharp(documentEditor); syntaxTree = ft.ReplaceSyntax(); } if (IsDocVB(doc)) { TransformFileVBasic ft = new TransformFileVBasic(documentEditor); syntaxTree = ft.ReplaceSyntax(); } File.WriteAllText(doc.FilePath.Replace(projectParentFolder, transformed_folder), syntaxTree.GetText().ToString()); Console.WriteLine("Transformed " + doc.FilePath); } HashSet <String> olddllSet = asMappingConnector.GetAllOldDllPaths(sdkId); TransformXml(olddllSet, sdkId, proj.FilePath, projectParentFolder, transformed_folder, Path.GetExtension(proj.FilePath)); Console.WriteLine("Transformed " + proj.FilePath); } else { Console.WriteLine("first parameter must be .csproj or .vbproj"); } }