Пример #1
0
        /// <summary>
        /// Initialyze the ClassAnalyzer. Must be call once.
        /// </summary>
        /// <param name="unsupportedMethods"></param>
        /// <param name="modules"></param>
        /// <param name="outputOptions"></param>
        private void Init(string coreASsemblyFolder, Dictionary <string, Dictionary <string, HashSet <string> > > unsupportedMethods, List <ModuleDefinition> modules, OutputOptions outputOptions = null)
        {
            if (!_isInitialized)
            {
                if (outputOptions == null)
                {
                    _outputOptions = new OutputOptions();
                }
                else
                {
                    _outputOptions = outputOptions;
                }
                if (!analyzeHelpher._initialized)
                {
                    CoreSupportedMethodsContainer coreSupportedMethods = new CoreSupportedMethodsContainer(coreASsemblyFolder);
                    analyzeHelpher.Initialize(coreSupportedMethods, Configuration.supportedElementsPath);
                }

                _implementedInterfaces = new HashSet <TypeReference>();
                _usings                     = new HashSet <string>();
                _customAttributes           = new HashSet <string>();
                _alreadyImplementedTypes    = new HashSet <string>();
                _dependencyProperties       = new HashSet <string>();
                _additionalTypesToImplement = new Dictionary <TypeReference, HashSet <string> >();
                _unsupportedMethods         = unsupportedMethods;
                _modules                    = modules;
                MethodAnalyzer              = new MethodAnalyzer(_unsupportedMethods, _modules, this, _outputOptions);
                _typeBuilder                = new TypeBuilder(_outputOptions, _modules);
                _isInitialized              = true;
            }
        }
Пример #2
0
        /// <summary>
        /// Retrieve all methods and types used in the _inputAssemblies and organize them in a Dictionary
        /// </summary>
        private void GetUnsupportedMethods()
        {
            ILogger logger = new LoggerThatAggregatesAllErrors();
            List <UnsupportedMethodInfo>  unsupportedMethodInfos = new List <UnsupportedMethodInfo>();
            CoreSupportedMethodsContainer coreSupportedMethods   = new CoreSupportedMethodsContainer(Configuration.SLMigrationCoreAssemblyFolderPath);

            foreach (string filename in _inputAssemblies)
            {
                CompatibilityAnalyzer.Analyze(
                    filename,
                    logger,
                    unsupportedMethodInfos,
                    coreSupportedMethods,
                    _inputAssemblies,
                    Configuration.UrlNamespacesThatBelongToUserCode,
                    new HashSet <string>(),
                    Configuration.ExcludedFiles,
                    Configuration.supportedElementsPath,
                    Configuration.mscorlibFolderPath,
                    Configuration.sdkFolderPath,
                    "",
                    skipTypesWhereNoMethodIsActuallyCalled: false,
                    addBothPropertyAndEventWhenNotFound: true,
                    additionalFolderWhereToResolveAssemblies: Configuration.ReferencedAssembliesFolderPath);
            }
            if (_unsupportedMethodsInfo == null)
            {
                _unsupportedMethodsInfo = new Dictionary <string, Dictionary <string, HashSet <string> > >();
            }
            HashSet <MethodInfo> unsupportedMethods = new HashSet <MethodInfo>();

            foreach (UnsupportedMethodInfo method in unsupportedMethodInfos)
            {
                unsupportedMethods.Add(new MethodInfo(method));
            }
            foreach (MethodInfo method in unsupportedMethods)
            {
                Tuple <string, string, string> methodInfo = GetMethodMainInfos(method);
                MethodInfo _method = new MethodInfo(methodInfo.Item1, methodInfo.Item2, methodInfo.Item3, method.NeedToBeCheckedBecauseOfInheritance);
                if (method.NeedToBeCheckedBecauseOfInheritance)
                {
                    _method = GetMethodInfoResolvingInheritance(_method.AssemblyName, _method.TypeName, _method.MethodName);
                }
                if (!_unsupportedMethodsInfo.ContainsKey(_method.AssemblyName))
                {
                    HashSet <string> methodsSet = new HashSet <string>();
                    if (_method.MethodName != "")
                    {
                        methodsSet.Add(_method.MethodName);
                    }
                    Dictionary <string, HashSet <string> > currentTypesDictionary = new Dictionary <string, HashSet <string> >
                    {
                        { _method.TypeName, methodsSet }
                    };
                    _unsupportedMethodsInfo.Add(_method.AssemblyName, currentTypesDictionary);
                }
                else
                {
                    if (!_unsupportedMethodsInfo[_method.AssemblyName].ContainsKey(_method.TypeName))
                    {
                        HashSet <string> methodsSet = new HashSet <string>();
                        if (_method.MethodName != "")
                        {
                            methodsSet.Add(_method.MethodName);
                        }
                        _unsupportedMethodsInfo[_method.AssemblyName].Add(_method.TypeName, methodsSet);
                    }
                    else
                    {
                        if (_method.MethodName != "")
                        {
                            _unsupportedMethodsInfo[_method.AssemblyName][_method.TypeName].Add(_method.MethodName);
                        }
                    }
                }
            }
        }