Example #1
0
 public NakedObjectsFramework(IMessageBroker messageBroker,
                              ISession session,
                              ILifecycleManager lifecycleManager,
                              IServicesManager servicesManager,
                              INakedObjectManager nakedObjectManager,
                              IObjectPersistor persistor,
                              IReflector reflector,
                              IMetamodelManager metamodelManagerManager,
                              IDomainObjectInjector domainObjectInjector,
                              NakedObjectFactory nakedObjectFactory,
                              SpecFactory memberFactory,
                              ITransactionManager transactionManager,
                              IFrameworkResolver frameworkResolver,
                              ILoggerFactory loggerFactory)
 {
     MessageBroker                  = messageBroker;
     Session                        = session;
     LifecycleManager               = lifecycleManager;
     ServicesManager                = servicesManager;
     NakedObjectManager             = nakedObjectManager;
     Persistor                      = persistor;
     Reflector                      = reflector;
     MetamodelManager               = metamodelManagerManager;
     DomainObjectInjector           = domainObjectInjector;
     TransactionManager             = transactionManager;
     FrameworkResolver              = frameworkResolver;
     domainObjectInjector.Framework = this;
     memberFactory.Initialize(this, loggerFactory, loggerFactory.CreateLogger <SpecFactory>());
     nakedObjectFactory.Initialize(metamodelManagerManager, session, lifecycleManager, persistor, nakedObjectManager, loggerFactory);
 }
 public NakedObjectsFramework(IMessageBroker messageBroker,
                              ISession session,
                              ILifecycleManager lifecycleManager,
                              IServicesManager servicesManager,
                              INakedObjectManager nakedObjectManager,
                              IObjectPersistor persistor,
                              IReflector reflector,
                              IMetamodelManager metamodelManagerManager,
                              IContainerInjector containerInjector,
                              NakedObjectFactory nakedObjectFactory,
                              SpecFactory memberFactory,
                              ITransactionManager transactionManager,
                              IFrameworkResolver frameworkResolver)
 {
     this.messageBroker           = messageBroker;
     this.session                 = session;
     this.lifecycleManager        = lifecycleManager;
     this.servicesManager         = servicesManager;
     this.nakedObjectManager      = nakedObjectManager;
     this.persistor               = persistor;
     this.reflector               = reflector;
     this.metamodelManagerManager = metamodelManagerManager;
     this.containerInjector       = containerInjector;
     this.transactionManager      = transactionManager;
     this.frameworkResolver       = frameworkResolver;
     containerInjector.Framework  = this;
     memberFactory.Initialize(this);
     nakedObjectFactory.Initialize(metamodelManagerManager, session, lifecycleManager, persistor, nakedObjectManager);
 }
 protected FrameworkVersion GetFrameworkVersionForModule(ModuleDefinition module, IFrameworkResolver frameworkResolver)
 {
     //TODO: handle Silverlight/WinPhone projects
     TargetPlatform platform = module.AssemblyResolver.GetTargetPlatform(module.FilePath);
     switch (platform)
     {
         case TargetPlatform.CLR_1:
             return FrameworkVersion.v1_1;
         case TargetPlatform.CLR_2:
             return FrameworkVersion.v2_0;
         case TargetPlatform.CLR_2_3:
         case TargetPlatform.CLR_3_5:
             return FrameworkVersion.v3_5;
         case TargetPlatform.CLR_4:
             return GetFramework4Version(module, frameworkResolver);
         case TargetPlatform.WinRT:
             return FrameworkVersion.WinRT;
         case TargetPlatform.Silverlight:
             return FrameworkVersion.Silverlight;
         case TargetPlatform.WindowsCE:
             return FrameworkVersion.WindowsCE;
         case TargetPlatform.WindowsPhone:
             return FrameworkVersion.WindowsPhone;
         default:
             return FrameworkVersion.Unknown;
     }
 }
 protected virtual void AddModulesFrameworkVersions(AssemblyInfo assemblyInfo, AssemblyDefinition assembly, IFrameworkResolver frameworkResolver)
 {
     foreach (ModuleDefinition module in assembly.Modules)
     {
         FrameworkVersion frameworkVersion = GetFrameworkVersionForModule(module, frameworkResolver);
         assemblyInfo.ModulesFrameworkVersions.Add(module, frameworkVersion);
     }
 }
        public AssemblyInfo GetAssemblyInfo(AssemblyDefinition assembly, IFrameworkResolver frameworkResolver)
        {
            AssemblyInfo assemblyInfo = new AssemblyInfo();

            AddModulesFrameworkVersions(assemblyInfo, assembly, frameworkResolver);

            return assemblyInfo;
        }
 public MSBuildProjectBuilder(string assemblyPath, string targetPath, ILanguage language,
                              IFrameworkResolver frameworkResolver, IDecompilationPreferences preferences, IFileGenerationNotifier notifier,
                              IAssemblyInfoService assemblyInfoService, ITargetPlatformResolver targetPlatformResolver, VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2010,
                              ProjectGenerationSettings projectGenerationSettings = null, IProjectGenerationNotifier projectNotifier = null)
     : base(assemblyPath, targetPath, language, frameworkResolver, preferences, notifier, assemblyInfoService, targetPlatformResolver, visualStudioVersion, projectGenerationSettings, projectNotifier)
 {
     this.projectFileManager = new MsBuildProjectFileManager(this.assembly, this.assemblyInfo, this.visualStudioVersion, this.modulesProjectsGuids, this.language, this.namespaceHierarchyTree);
 }
Example #7
0
        public AssemblyInfo GetAssemblyInfo(AssemblyDefinition assembly, IFrameworkResolver frameworkResolver)
        {
            AssemblyInfo assemblyInfo = new AssemblyInfo();

            AddModulesFrameworkVersions(assemblyInfo, assembly, frameworkResolver);

            return(assemblyInfo);
        }
Example #8
0
        public static ProjectGenerationSettings GetProjectGenerationSettings(string assemblyFilePath, IAssemblyInfoService assemblyInfoService,
                                                                             IFrameworkResolver frameworkResolver, VisualStudioVersion visualStudioVersion, ILanguage language, ITargetPlatformResolver targetPlatformResolver)
        {
            AssemblyDefinition assembly       = Telerik.JustDecompiler.Decompiler.Utilities.GetAssembly(assemblyFilePath);
            AssemblyInfo       assemblyInfo   = assemblyInfoService.GetAssemblyInfo(assembly, frameworkResolver, targetPlatformResolver);
            TargetPlatform     targetPlatform = GlobalAssemblyResolver.Instance.GetTargetPlatform(assemblyFilePath, targetPlatformResolver);

            foreach (KeyValuePair <ModuleDefinition, FrameworkVersion> pair in assemblyInfo.ModulesFrameworkVersions)
            {
                if (pair.Value == FrameworkVersion.Unknown)
                {
                    return(new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToUnknownFrameworkVersion, false));
                }
                else if (pair.Value == FrameworkVersion.WindowsCE ||
                         (targetPlatform == TargetPlatform.WindowsPhone && pair.Value == FrameworkVersion.WindowsPhone) ||
                         (targetPlatform == TargetPlatform.WinRT && WinRTProjectTypeDetector.GetProjectType(assembly) == WinRTProjectType.Unknown))
                {
                    return(new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToNotSupportedProjectType, false));
                }
            }

            string resultErrorMessage;

            if (visualStudioVersion == VisualStudioVersion.VS2010)
            {
                if (!CanBe2010ProjectCreated(assemblyInfo, targetPlatform, out resultErrorMessage))
                {
                    return(new ProjectGenerationSettings(false, resultErrorMessage));
                }
            }
            else if (visualStudioVersion == VisualStudioVersion.VS2012)
            {
                if (!CanBe2012ProjectCreated(assembly, out resultErrorMessage))
                {
                    return(new ProjectGenerationSettings(false, resultErrorMessage));
                }
            }
            else
            {
                if (targetPlatform == TargetPlatform.WinRT && language is IVisualBasic &&
                    WinRTProjectTypeDetector.GetProjectType(assembly) == WinRTProjectType.ComponentForUniversal)
                {
                    resultErrorMessage = string.Format(ResourceStrings.CannotCreateProjectForComponentForUniversalInVB, visualStudioVersion.ToFriendlyString());
                    return(new ProjectGenerationSettings(false, resultErrorMessage));
                }

                if (visualStudioVersion == VisualStudioVersion.VS2013)
                {
                    if (!CanBe2013ProjectCreated(assembly, language, out resultErrorMessage))
                    {
                        return(new ProjectGenerationSettings(false, resultErrorMessage));
                    }
                }
            }

            return(new ProjectGenerationSettings(true));
        }
Example #9
0
        public AssemblyInfo GetAssemblyInfo(AssemblyDefinition assembly, IFrameworkResolver frameworkResolver, ITargetPlatformResolver targetPlatformResolver)
        {
            AssemblyInfo assemblyInfo = new AssemblyInfo();

            AddModulesFrameworkVersions(assemblyInfo, assembly, frameworkResolver, targetPlatformResolver);
            AddAssemblyTypes(assemblyInfo, assembly);

            return(assemblyInfo);
        }
        protected virtual FrameworkVersion GetFramework4Version(ModuleDefinition module, IFrameworkResolver frameworkResolver)
        {
            FrameworkVersion frameworkVersion;
            if (!TryDetectFramework4Upgrade(module, out frameworkVersion))
            {
                frameworkVersion = frameworkResolver.GetDefaultFallbackFramework4Version();
            }

            return frameworkVersion;
        }
 public MSBuildProjectBuilder(string assemblyPath, AssemblyDefinition assembly,
                              Dictionary <ModuleDefinition, Mono.Collections.Generic.Collection <TypeDefinition> > userDefinedTypes,
                              Dictionary <ModuleDefinition, Mono.Collections.Generic.Collection <Resource> > resources,
                              string targetPath, ILanguage language, IFrameworkResolver frameworkResolver,
                              IDecompilationPreferences preferences, IAssemblyInfoService assemblyInfoService, ITargetPlatformResolver targetPlatformResolver,
                              VisualStudioVersion visualStudioVersion    = VisualStudioVersion.VS2010, ProjectGenerationSettings projectGenerationSettings = null,
                              IProjectGenerationNotifier projectNotifier = null)
     : base(assemblyPath, assembly, userDefinedTypes, resources, targetPath, language, frameworkResolver, preferences, assemblyInfoService, targetPlatformResolver, visualStudioVersion, projectGenerationSettings, projectNotifier)
 {
     this.projectFileManager = new MsBuildProjectFileManager(this.assembly, this.assemblyInfo, this.visualStudioVersion, this.modulesProjectsGuids, this.language, this.namespaceHierarchyTree);
 }
Example #12
0
        public BaseProjectBuilder(string assemblyPath, AssemblyDefinition assembly,
                                  Dictionary <ModuleDefinition, Mono.Collections.Generic.Collection <TypeDefinition> > userDefinedTypes,
                                  Dictionary <ModuleDefinition, Mono.Collections.Generic.Collection <Resource> > resources,
                                  string targetPath, ILanguage language, IFrameworkResolver frameworkResolver,
                                  IDecompilationPreferences preferences, IAssemblyInfoService assemblyInfoService, ITargetPlatformResolver targetPlatformResolver,
                                  VisualStudioVersion visualStudioVersion    = VisualStudioVersion.VS2010, ProjectGenerationSettings projectGenerationSettings = null,
                                  IProjectGenerationNotifier projectNotifier = null)
        {
            this.assemblyPath            = assemblyPath;
            this.assembly                = assembly;
            this.userDefinedTypes        = userDefinedTypes;
            this.resources               = resources;
            this.TargetPath              = targetPath;
            this.targetDir               = Path.GetDirectoryName(targetPath);
            this.targetPlatformResolver  = targetPlatformResolver;
            this.language                = language;
            this.frameworkResolver       = frameworkResolver;
            this.assemblyInfoService     = assemblyInfoService;
            this.currentAssemblyResolver = assembly.MainModule.AssemblyResolver;

            this.visualStudioVersion       = visualStudioVersion;
            this.projectGenerationSettings = projectGenerationSettings;

            this.decompilationPreferences = preferences;

            this.platform = currentAssemblyResolver.GetTargetPlatform(assembly.MainModule.FilePath, TargetPlatformResolver.Instance);
            this.namespaceHierarchyTree = assembly.BuildNamespaceHierarchyTree();

            filePathsService =
                new DefaultFilePathsService(
                    this.assembly,
                    this.assemblyPath,
                    Path.GetFileName(this.TargetPath),
                    this.UserDefinedTypes,
                    this.Resources,
                    this.namespaceHierarchyTree,
                    this.language,
                    Utilities.GetMaxRelativePathLength(targetPath));
            filePathsService.ExceptionThrown += OnExceptionThrown;

            this.resourcesToPathsMap           = this.filePathsService.GetResourcesToFilePathsMap();
            this.xamlResourcesToPathsMap       = this.filePathsService.GetXamlResourcesToFilePathsMap();
            this.modulesToProjectsFilePathsMap = this.filePathsService.GetModulesToProjectsFilePathsMap();

            this.assemblyInfo         = this.assemblyInfoService.GetAssemblyInfo(this.assembly, this.frameworkResolver, this.targetPlatformResolver);
            this.projectNotifier      = projectNotifier;
            this.modulesProjectsGuids = new Dictionary <ModuleDefinition, Guid>();
        }
        public BaseProjectBuilder(string assemblyPath, string targetPath, ILanguage language,
                                  IFrameworkResolver frameworkResolver, IDecompilationPreferences preferences, IFileGenerationNotifier notifier,
                                  IAssemblyInfoService assemblyInfoService, VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2010,
                                  ProjectGenerationSettings projectGenerationSettings = null, IProjectGenerationNotifier projectNotifier = null)
        {
            this.assemblyPath = assemblyPath;
            this.TargetPath   = targetPath;
            this.targetDir    = Path.GetDirectoryName(targetPath);
            this.language     = language;

            this.frameworkResolver         = frameworkResolver;
            this.assemblyInfoService       = assemblyInfoService;
            this.decompilationPreferences  = preferences;
            this.visualStudioVersion       = visualStudioVersion;
            this.projectGenerationSettings = projectGenerationSettings;

            this.currentAssemblyResolver = new WeakAssemblyResolver(GlobalAssemblyResolver.CurrentAssemblyPathCache);

            var readerParameters = new ReaderParameters(currentAssemblyResolver);

            assembly = currentAssemblyResolver.LoadAssemblyDefinition(assemblyPath, readerParameters, loadPdb: true);

            this.namespaceHierarchyTree = assembly.BuildNamespaceHierarchyTree();

            filePathsService =
                new DefaultFilePathsService(
                    this.assembly,
                    this.assemblyPath,
                    Path.GetFileName(this.TargetPath),
                    this.UserDefinedTypes,
                    this.Resources,
                    this.namespaceHierarchyTree,
                    this.language,
                    Utilities.GetMaxRelativePathLength(targetPath),
                    this.decompilationPreferences.DecompileDangerousResources);
            filePathsService.ExceptionThrown += OnExceptionThrown;

            this.modulesToProjectsFilePathsMap = this.filePathsService.GetModulesToProjectsFilePathsMap();
            this.fileGeneratedNotifier         = notifier;

            this.resourcesToPathsMap     = this.filePathsService.GetResourcesToFilePathsMap();
            this.xamlResourcesToPathsMap = this.filePathsService.GetXamlResourcesToFilePathsMap();

            this.assemblyInfo         = this.assemblyInfoService.GetAssemblyInfo(this.assembly, this.frameworkResolver);
            this.projectNotifier      = projectNotifier;
            this.modulesProjectsGuids = new Dictionary <ModuleDefinition, Guid>();
        }
        public static ProjectGenerationSettings GetProjectGenerationSettings(string assemblyFilePath, IAssemblyInfoService assemblyInfoService,
                                                                             IFrameworkResolver frameworkResolver, VisualStudioVersion visualStudioVersion, ILanguage language)
        {
            AssemblyDefinition assembly     = Telerik.JustDecompiler.Decompiler.Utilities.GetAssembly(assemblyFilePath);
            AssemblyInfo       assemblyInfo = assemblyInfoService.GetAssemblyInfo(assembly, frameworkResolver);

            foreach (KeyValuePair <ModuleDefinition, FrameworkVersion> pair in assemblyInfo.ModulesFrameworkVersions)
            {
                if (pair.Value == FrameworkVersion.Unknown)
                {
                    return(new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToUnknownFrameworkVersion, false));
                }
                else if (pair.Value == FrameworkVersion.WindowsCE || pair.Value == FrameworkVersion.WindowsPhone ||
                         (pair.Value == FrameworkVersion.WinRT && WinRTProjectTypeDetector.GetProjectType(assembly) == WinRTProjectType.Unknown))
                {
                    return(new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToNotSupportedProjectType, false));
                }
            }

            string resultErrorMessage;

            if (visualStudioVersion == VisualStudioVersion.VS2010)
            {
                if (!CanBe2010ProjectCreated(assemblyInfo, out resultErrorMessage))
                {
                    return(new ProjectGenerationSettings(false, resultErrorMessage));
                }
            }
            else if (visualStudioVersion == VisualStudioVersion.VS2012)
            {
                if (!CanBe2012ProjectCreated(assembly, out resultErrorMessage))
                {
                    return(new ProjectGenerationSettings(false, resultErrorMessage));
                }
            }
            else if (visualStudioVersion == VisualStudioVersion.VS2013)
            {
                if (!CanBe2013ProjectCreated(assembly, language, out resultErrorMessage))
                {
                    return(new ProjectGenerationSettings(false, resultErrorMessage));
                }
            }

            return(new ProjectGenerationSettings(true));
        }
        public static ProjectGenerationSettings GetProjectGenerationSettings(string assemblyFilePath, IAssemblyInfoService assemblyInfoService,
            IFrameworkResolver frameworkResolver, VisualStudioVersion visualStudioVersion, ILanguage language)
        {
            AssemblyDefinition assembly = Telerik.JustDecompiler.Decompiler.Utilities.GetAssembly(assemblyFilePath);
            AssemblyInfo assemblyInfo = assemblyInfoService.GetAssemblyInfo(assembly, frameworkResolver);
            foreach (KeyValuePair<ModuleDefinition, FrameworkVersion> pair in assemblyInfo.ModulesFrameworkVersions)
            {
                if (pair.Value == FrameworkVersion.Unknown)
                {
                    return new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToUnknownFrameworkVersion, false);
                }
                else if (pair.Value == FrameworkVersion.WindowsCE || pair.Value == FrameworkVersion.WindowsPhone ||
                    (pair.Value == FrameworkVersion.WinRT && WinRTProjectTypeDetector.GetProjectType(assembly) == WinRTProjectType.Unknown))
                {
                    return new ProjectGenerationSettings(true, ResourceStrings.GenerateOnlySourceFilesDueToNotSupportedProjectType, false);
                }
            }

            string resultErrorMessage;
            if (visualStudioVersion == VisualStudioVersion.VS2010)
            {
                if (!CanBe2010ProjectCreated(assemblyInfo, out resultErrorMessage))
                {
                    return new ProjectGenerationSettings(false, resultErrorMessage);
                }
            }
            else if (visualStudioVersion == VisualStudioVersion.VS2012)
            {
                if (!CanBe2012ProjectCreated(assembly, out resultErrorMessage))
                {
                    return new ProjectGenerationSettings(false, resultErrorMessage);
                }
            }
            else if (visualStudioVersion == VisualStudioVersion.VS2013)
            {
                if (!CanBe2013ProjectCreated(assembly, language, out resultErrorMessage))
                {
                    return new ProjectGenerationSettings(false, resultErrorMessage);
                }
            }

            return new ProjectGenerationSettings(true);
        }
Example #16
0
        private BaseProjectBuilder GetProjectBuilder(AssemblyDefinition assembly, GeneratorProjectInfo projectInfo, ProjectGenerationSettings settings, ILanguage language, string projFilePath, DecompilationPreferences preferences, IFrameworkResolver frameworkResolver, ITargetPlatformResolver targetPlatformResolver)
        {
            TargetPlatform     targetPlatform = targetPlatformResolver.GetTargetPlatform(assembly.MainModule.FilePath, assembly.MainModule);
            BaseProjectBuilder projectBuilder = null;

            if (targetPlatform == TargetPlatform.NetCore)
            {
                projectBuilder = new NetCoreProjectBuilder(projectInfo.Target, projFilePath, language, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
            }
            else if (targetPlatform == TargetPlatform.WinRT)
            {
                projectBuilder = new WinRTProjectBuilder(projectInfo.Target, projFilePath, language, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
            }
            else
            {
                projectBuilder = new MSBuildProjectBuilder(projectInfo.Target, projFilePath, language, frameworkResolver, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
            }

            return(projectBuilder);
        }
Example #17
0
        protected FrameworkVersion GetFrameworkVersionForModule(ModuleDefinition module, IFrameworkResolver frameworkResolver)
        {
            //TODO: handle Silverlight/WinPhone projects
            TargetPlatform platform = module.AssemblyResolver.GetTargetPlatform(module.FilePath);

            switch (platform)
            {
            case TargetPlatform.CLR_1:
                return(FrameworkVersion.v1_1);

            case TargetPlatform.CLR_2:
                return(FrameworkVersion.v2_0);

            case TargetPlatform.CLR_2_3:
            case TargetPlatform.CLR_3_5:
                return(FrameworkVersion.v3_5);

            case TargetPlatform.CLR_4:
                return(GetFramework4Version(module, frameworkResolver));

            case TargetPlatform.WinRT:
                return(FrameworkVersion.WinRT);

            case TargetPlatform.Silverlight:
                return(FrameworkVersion.Silverlight);

            case TargetPlatform.WindowsCE:
                return(FrameworkVersion.WindowsCE);

            case TargetPlatform.WindowsPhone:
                return(FrameworkVersion.WindowsPhone);

            default:
                return(FrameworkVersion.Unknown);
            }
        }
Example #18
0
        protected virtual FrameworkVersion GetFramework4Version(ModuleDefinition module, IFrameworkResolver frameworkResolver)
        {
            FrameworkVersion frameworkVersion;

            if (!TryDetectFramework4Upgrade(module, out frameworkVersion))
            {
                frameworkVersion = frameworkResolver.GetDefaultFallbackFramework4Version();
            }

            return(frameworkVersion);
        }
Example #19
0
 protected virtual void AddModulesFrameworkVersions(AssemblyInfo assemblyInfo, AssemblyDefinition assembly, IFrameworkResolver frameworkResolver)
 {
     foreach (ModuleDefinition module in assembly.Modules)
     {
         FrameworkVersion frameworkVersion = GetFrameworkVersionForModule(module, frameworkResolver);
         assemblyInfo.ModulesFrameworkVersions.Add(module, frameworkVersion);
     }
 }
        public MSBuildProjectBuilder(string assemblyPath, string targetPath, ILanguage language,
            IFrameworkResolver frameworkResolver,IDecompilationPreferences preferences, IFileGenerationNotifier notifier,
            IAssemblyInfoService assemblyInfoService, VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2010,
			ProjectGenerationSettings projectGenerationSettings = null, IProjectGenerationNotifier projectNotifier = null)
        {
            this.assemblyPath = assemblyPath;
            this.TargetPath = targetPath;
			this.targetDir = Path.GetDirectoryName(targetPath);
            this.language = language;

            this.frameworkResolver = frameworkResolver;
            this.decompilationPreferences = preferences;
            this.assemblyInfoService = assemblyInfoService;
            this.visualStudioVersion = visualStudioVersion;
            this.projectGenerationSettings = projectGenerationSettings;

            this.currentAssemblyResolver = new WeakAssemblyResolver(GlobalAssemblyResolver.CurrentAssemblyPathCache);

            var readerParameters = new ReaderParameters(currentAssemblyResolver);
            assembly = currentAssemblyResolver.LoadAssemblyDefinition(assemblyPath, readerParameters, loadPdb: true);

            platform = currentAssemblyResolver.GetTargetPlatform(assemblyPath);
            namespaceHierarchyTree = assembly.BuildNamespaceHierarchyTree();

            filePathsService =
                new DefaultFilePathsService(
					this.assembly,
                    this.assemblyPath,
					Path.GetFileName(this.TargetPath),
                    this.UserDefinedTypes,
                    this.Resources,
                    namespaceHierarchyTree,
                    this.language,
                    Utilities.GetMaxRelativePathLength(targetPath));

			this.modulesToProjectsFilePathsMap = this.filePathsService.GetModulesToProjectsFilePathsMap();
			this.resourcesToPathsMap = this.filePathsService.GetResourcesToFilePathsMap();
			this.xamlResourcesToPathsMap = this.filePathsService.GetXamlResourcesToFilePathsMap();
            this.fileGeneratedNotifier = notifier;

			this.assemblyInfo = GetAssemblyInfo();
			this.projectNotifier = projectNotifier;
        }
Example #21
0
 protected FrameworkVersion GetFrameworkVersionForModule(ModuleDefinition module, IFrameworkResolver frameworkResolver)
 {
     if (assemblyFrameworkResolver.IsCLR4Assembly(module))
     {
         return(this.GetFramework4Version(module, frameworkResolver));
     }
     else
     {
         return(assemblyFrameworkResolver.GetFrameworkVersionForModule(module));
     }
 }
        public const int MaxPathLength = 259; // 259 + NULL == 260

        public MSBuildProjectBuilder(string assemblyPath, AssemblyDefinition assembly,
            Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<TypeDefinition>> userDefinedTypes,
 			Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<Resource>> resources,
			string targetPath, ILanguage language, IFrameworkResolver frameworkResolver,
            IDecompilationPreferences preferences, IAssemblyInfoService assemblyInfoService,
			VisualStudioVersion visualStudioVersion = VisualStudioVersion.VS2010, ProjectGenerationSettings projectGenerationSettings = null,
			IProjectGenerationNotifier projectNotifier = null)
        {
            this.assemblyPath = assemblyPath;
            this.assembly = assembly;
            this.userDefinedTypes = userDefinedTypes;
			this.resources = resources;
            this.TargetPath = targetPath;
			this.targetDir = Path.GetDirectoryName(targetPath);
            this.language = language;
            this.frameworkResolver = frameworkResolver;
            this.assemblyInfoService = assemblyInfoService;
            this.visualStudioVersion = visualStudioVersion;
            this.projectGenerationSettings = projectGenerationSettings;

            this.currentAssemblyResolver = assembly.MainModule.AssemblyResolver;
			this.decompilationPreferences = preferences;

            platform = currentAssemblyResolver.GetTargetPlatform(assembly.MainModule.FilePath);
            namespaceHierarchyTree = assembly.BuildNamespaceHierarchyTree();

            filePathsService =
                new DefaultFilePathsService(
					this.assembly,
                    this.assemblyPath,
					Path.GetFileName(this.TargetPath),
                    this.UserDefinedTypes,
                    this.Resources,
                    namespaceHierarchyTree,
                    this.language,
                    Utilities.GetMaxRelativePathLength(targetPath));

			this.modulesToProjectsFilePathsMap = this.filePathsService.GetModulesToProjectsFilePathsMap();
			this.resourcesToPathsMap = this.filePathsService.GetResourcesToFilePathsMap();
			this.xamlResourcesToPathsMap = this.filePathsService.GetXamlResourcesToFilePathsMap();

			this.assemblyInfo = GetAssemblyInfo();
			this.projectNotifier = projectNotifier;
        }
 private MSBuildProjectBuilder GetProjectBuilder(AssemblyDefinition assembly, GeneratorProjectInfo projectInfo, ProjectGenerationSettings settings, ILanguage language, string projFilePath, DecompilationPreferences preferences, IFrameworkResolver frameworkResolver)
 {
     TargetPlatform targetPlatform = assembly.MainModule.AssemblyResolver.GetTargetPlatform(assembly.MainModule.FilePath);
     if (targetPlatform == TargetPlatform.WinRT)
     {
         return new WinRTProjectBuilder(projectInfo.Target, projFilePath, language, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
     }
     else
     {
         return new MSBuildProjectBuilder(projectInfo.Target, projFilePath, language, frameworkResolver, preferences, null, NoCacheAssemblyInfoService.Instance, projectInfo.VisualStudioVersion, settings);
     }
 }