Exemplo n.º 1
0
        private void UpdateContext(Solution solution, Project project, Compilation compilation, ReflectionCache reflectionCache)
        {
            Solution        = solution;
            Project         = project;
            Compilation     = compilation;
            SymbolNames     = new SymbolNameMap(new Dictionary <ISymbol, string>());//SymbolNameCompiler.CompileSymbolNames(project, compilation);
            ReflectionCache = reflectionCache;

//            var diagnostics = compilation.GetDiagnostics();
//            var mscorlib = compilation.GetReferencedAssemblySymbol(project.MetadataReferences.First());
//            var typeNames = mscorlib.TypeNames.OrderBy(x => x).ToArray();

            ObjectToString                  = compilation.ObjectType.GetMembers("ToString").OfType <IMethodSymbol>().Single();
            String                          = compilation.FindType("System.String");
            SpecialFunctions                = compilation.FindType("System.Runtime.WootzJs.SpecialFunctions");
            DefaultOf                       = SpecialFunctions.GetMethod("DefaultOf");
            Char                            = compilation.FindType("System.Char");
            Byte                            = compilation.FindType("System.Byte");
            Int16                           = compilation.FindType("System.Int16");
            Int32                           = compilation.FindType("System.Int32");
            Int64                           = compilation.FindType("System.Int64");
            SByte                           = compilation.FindType("System.SByte");
            UInt16                          = compilation.FindType("System.UInt16");
            UInt32                          = compilation.FindType("System.UInt32");
            UInt64                          = compilation.FindType("System.UInt64");
            Single                          = compilation.FindType("System.Single");
            Double                          = compilation.FindType("System.Double");
            Decimal                         = compilation.FindType("System.Decimal");
            Exception                       = compilation.FindType("System.Exception");
            InternalInit                    = Exception.GetMethodByName("InternalInit");
            Assembly                        = compilation.FindType("System.Reflection.Assembly");
            AssemblyConstructor             = Assembly.InstanceConstructors.Single();
            JsAttributeType                 = compilation.FindType("System.Runtime.WootzJs.JsAttribute");
            PrecedesAttribute               = compilation.FindType("System.Runtime.WootzJs.DependsOnAttribute");
            ObjectType                      = compilation.FindType("System.Object");
            GetType                         = ObjectType.GetMethod("GetType");
            ObjectReferenceEquals           = (IMethodSymbol)ObjectType.GetMembers("ReferenceEquals").Single();
            ObjectCast                      = (IMethodSymbol)SpecialFunctions.GetMembers("ObjectCast").Single();
            ObjectCreateDelegate            = (IMethodSymbol)SpecialFunctions.GetMembers("CreateDelegate").Single();
            TypeType                        = compilation.FindType("System.Type");
            TypeArray                       = compilation.CreateArrayTypeSymbol(TypeType);
            TypeConstructor                 = TypeType.InstanceConstructors.Single();
            TypeInit                        = (IMethodSymbol)TypeType.GetMembers("Init").Single();
            CreateTypeParameter             = (IMethodSymbol)TypeType.GetMembers("CreateTypeParameter").Single();
            TypeIsInstanceOfType            = (IMethodSymbol)TypeType.GetMembers("IsInstanceOfType").Single();
            Type_GetTypeFromTypeFunc        = (IMethodSymbol)TypeType.GetMembers("_GetTypeFromTypeFunc").Single();
            GetField                        = TypeType.GetMethod("GetField", String);
            GetProperty                     = TypeType.GetMethod("GetProperty", String);
            GetMethod                       = TypeType.GetMethod("GetMethod", String, TypeArray);
            GetConstructor                  = TypeType.GetMethod("GetConstructor", TypeArray);
            AsExtensionType                 = compilation.FindType("System.Runtime.WootzJs.AsExtension");
            JsniType                        = compilation.FindType("System.Runtime.WootzJs.Jsni");
            EnumType                        = compilation.FindType("System.Enum");
            EnumGetValue                    = EnumType.GetMethod("GetValue");
            EnumInternalToObject            = EnumType.GetMethod("InternalToObject");
            Enumerable                      = compilation.FindType("System.Collections.IEnumerable");
            EnumerableGeneric               = compilation.FindType("System.Collections.Generic.IEnumerable`1");
            Enumerator                      = compilation.FindType("System.Collections.IEnumerator");
            EnumerableGetEnumerator         = (IMethodSymbol)Enumerable.GetMembers("GetEnumerator").Single();
            EnumeratorCurrent               = (IPropertySymbol)Enumerator.GetMembers("Current").Single();
            EnumeratorMoveNext              = (IMethodSymbol)Enumerator.GetMembers("MoveNext").Single();
            DelegateType                    = compilation.FindType("System.Delegate");
            DelegateTypeConstructor         = DelegateType.InstanceConstructors.Single();
            DelegateTarget                  = (IPropertySymbol)DelegateType.GetMembers("Target").Single();
            DelegateCombine                 = DelegateType.GetMembers("Combine").OfType <IMethodSymbol>().Single(x => x.Parameters.Count() == 2 && x.Parameters.All(y => Equals(y.Type, DelegateType)));
            DelegateRemove                  = DelegateType.GetMembers("Remove").OfType <IMethodSymbol>().Single(x => x.Parameters.Count() == 2 && x.Parameters.All(y => Equals(y.Type, DelegateType)));
            MulticastDelegateType           = compilation.FindType("System.MulticastDelegate");
            MulticastDelegateConstructor    = MulticastDelegateType.InstanceConstructors.Single(x => x.Parameters.Last().Type.TypeKind == TypeKind.ArrayType);
            NullableType                    = compilation.FindType("System.Nullable`1");
            CharNullable                    = NullableType.Construct(Char);
            NullableHasValue                = (IPropertySymbol)NullableType.GetMembers("HasValue").Single();
            NullableValue                   = (IPropertySymbol)NullableType.GetMembers("Value").Single();
            NullableGetValueOrDefault       = (IMethodSymbol)NullableType.GetMembers("GetValueOrDefault").Single();
            FieldInfo                       = compilation.FindType("System.Reflection.FieldInfo");
            MethodInfo                      = compilation.FindType("System.Reflection.MethodInfo");
            MemberInfo                      = compilation.FindType("System.Reflection.MemberInfo");
            PropertyInfo                    = compilation.FindType("System.Reflection.PropertyInfo");
            EventInfo                       = compilation.FindType("System.Reflection.EventInfo");
            ConstructorInfo                 = compilation.FindType("System.Reflection.ConstructorInfo");
            Attribute                       = compilation.FindType("System.Attribute");
            FieldInfoConstructor            = FieldInfo.InstanceConstructors.Single();
            MethodInfoConstructor           = MethodInfo.InstanceConstructors.Single();
            ParameterInfo                   = compilation.FindType("System.Reflection.ParameterInfo");
            ParameterInfoConstructor        = ParameterInfo.InstanceConstructors.Single();
            PropertyInfoConstructor         = PropertyInfo.InstanceConstructors.Single();
            EventInfoConstructor            = EventInfo.InstanceConstructors.Single();
            ConstructorInfoConstructor      = ConstructorInfo.InstanceConstructors.Single();
            TypeAttributes                  = compilation.FindType("System.Reflection.TypeAttributes");
            TypeAttributesPublic            = (IFieldSymbol)TypeAttributes.GetMembers("Public").Single();
            TypeAttributesNotPublic         = (IFieldSymbol)TypeAttributes.GetMembers("NotPublic").Single();
            TypeAttributesNestedPublic      = (IFieldSymbol)TypeAttributes.GetMembers("NestedPublic").Single();
            TypeAttributesNestedPrivate     = (IFieldSymbol)TypeAttributes.GetMembers("NestedPrivate").Single();
            TypeAttributesNestedFamily      = (IFieldSymbol)TypeAttributes.GetMembers("NestedFamily").Single();
            TypeAttributesNestedAssembly    = (IFieldSymbol)TypeAttributes.GetMembers("NestedAssembly").Single();
            TypeAttributesNestedFamANDAssem = (IFieldSymbol)TypeAttributes.GetMembers("NestedFamANDAssem").Single();
            TypeAttributesNestedFamORAssem  = (IFieldSymbol)TypeAttributes.GetMembers("NestedFamORAssem").Single();
            TypeAttributesAbstract          = (IFieldSymbol)TypeAttributes.GetMembers("Abstract").Single();
            TypeAttributesSealed            = (IFieldSymbol)TypeAttributes.GetMembers("Sealed").Single();
            TypeAttributesClass             = (IFieldSymbol)TypeAttributes.GetMembers("Class").Single();
            TypeAttributesInterface         = (IFieldSymbol)TypeAttributes.GetMembers("Interface").Single();
            FieldAttributes                 = compilation.FindType("System.Reflection.FieldAttributes");
            FieldAttributesPublic           = (IFieldSymbol)FieldAttributes.GetMembers("Public").Single();
            FieldAttributesPrivate          = (IFieldSymbol)FieldAttributes.GetMembers("Private").Single();
            FieldAttributesFamily           = (IFieldSymbol)FieldAttributes.GetMembers("Family").Single();
            FieldAttributesAssembly         = (IFieldSymbol)FieldAttributes.GetMembers("Assembly").Single();
            FieldAttributesFamORAssem       = (IFieldSymbol)FieldAttributes.GetMembers("FamORAssem").Single();
            FieldAttributesStatic           = (IFieldSymbol)FieldAttributes.GetMembers("Static").Single();
            FieldAttributesInitOnly         = (IFieldSymbol)FieldAttributes.GetMembers("InitOnly").Single();
            FieldAttributesLiteral          = (IFieldSymbol)FieldAttributes.GetMembers("Literal").Single();
            MethodAttributes                = compilation.FindType("System.Reflection.MethodAttributes");
            MethodAttributesPublic          = (IFieldSymbol)MethodAttributes.GetMembers("Public").Single();
            MethodAttributesPrivate         = (IFieldSymbol)MethodAttributes.GetMembers("Private").Single();
            MethodAttributesFamily          = (IFieldSymbol)MethodAttributes.GetMembers("Family").Single();
            MethodAttributesAssembly        = (IFieldSymbol)MethodAttributes.GetMembers("Assembly").Single();
            MethodAttributesFamORAssem      = (IFieldSymbol)MethodAttributes.GetMembers("FamORAssem").Single();
            MethodAttributesStatic          = (IFieldSymbol)MethodAttributes.GetMembers("Static").Single();
            ParameterAttributes             = compilation.FindType("System.Reflection.ParameterAttributes");
            ParameterAttributesOut          = (IFieldSymbol)ParameterAttributes.GetMembers("Out").Single();
            ParameterAttributesHasDefault   = (IFieldSymbol)ParameterAttributes.GetMembers("HasDefault").Single();
            ParameterAttributesNone         = (IFieldSymbol)ParameterAttributes.GetMembers("None").Single();
            JsFunction                      = compilation.FindType("System.Runtime.WootzJs.JsFunction");
            IDisposable                     = compilation.FindType("System.IDisposable");
            IDisposableDispose              = (IMethodSymbol)IDisposable.GetMembers("Dispose").Single();
            Expression                      = compilation.FindType("System.Linq.Expressions.Expression");
            ExpressionGeneric               = compilation.FindType("System.Linq.Expressions.Expression`1");
            ExpressionArray                 = compilation.CreateArrayTypeSymbol(Expression);
            ExpressionType                  = compilation.FindType("System.Linq.Expressions.ExpressionType");
            ExpressionLambda                = compilation.FindType("System.Linq.Expressions.Expression`1");
            ParameterExpression             = compilation.FindType("System.Linq.Expressions.ParameterExpression");
            ParameterExpressionArray        = compilation.CreateArrayTypeSymbol(ParameterExpression);
            NewExpression                   = compilation.FindType("System.Linq.Expressions.NewExpression");
            MemberBinding                   = compilation.FindType("System.Linq.Expressions.MemberBinding");
            MemberBindingArray              = compilation.CreateArrayTypeSymbol(MemberBinding);
            ElementInit                     = compilation.FindType("System.Linq.Expressions.ElementInit");
            ElementInitArray                = compilation.CreateArrayTypeSymbol(ElementInit);
            Constant                        = compilation.FindType("System.Linq.Expressions.ConstantExpression");
            Action                          = compilation.FindType("System.Action");
            ActionT                         = compilation.FindType("System.Action`1");
            Func                            = compilation.FindType("System.Func`1");
            JsObject                        = compilation.FindType("System.Runtime.WootzJs.JsObject");
            JsString                        = compilation.FindType("System.Runtime.WootzJs.JsString");
            SafeToString                    = SpecialFunctions.GetMembers("SafeToString").OfType <IMethodSymbol>().Single();
            Array                           = compilation.FindType("System.Array");
            INotifyPropertyChanged          = compilation.FindType("System.ComponentModel.INotifyPropertyChanged");
            Task                            = compilation.FindType("System.Threading.Tasks.Task");
            TaskT                           = compilation.FindType("System.Threading.Tasks.Task`1");
            TaskAwaiter                     = compilation.FindType("System.Runtime.CompilerServices.TaskAwaiter");
            TaskAwaiterT                    = compilation.FindType("System.Runtime.CompilerServices.TaskAwaiter`1");
            Nop = compilation.FindType("System.Runtime.CompilerServices.Op").GetMethod("Nothing");
            AsyncVoidMethodBuilder        = compilation.FindType("System.Runtime.CompilerServices.AsyncVoidMethodBuilder");
            AsyncVoidMethodBuilderCreate  = AsyncVoidMethodBuilder.GetMethod("Create");
            AsyncVoidMethodBuilderStart   = AsyncVoidMethodBuilder.GetMethod("Start");
            AsyncTaskMethodBuilder        = compilation.FindType("System.Runtime.CompilerServices.AsyncTaskMethodBuilder");
            AsyncTaskMethodBuilderCreate  = AsyncTaskMethodBuilder.GetMethod("Create");
            AsyncTaskMethodBuilderStart   = AsyncTaskMethodBuilder.GetMethod("Start");
            AsyncTaskTMethodBuilder       = compilation.FindType("System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1");
            AsyncTaskTMethodBuilderCreate = AsyncTaskTMethodBuilder.GetMethod("Create");
            AsyncTaskTMethodBuilderStart  = AsyncTaskTMethodBuilder.GetMethod("Start");
            CallerMemberNameAttribute     = compilation.FindType("System.Runtime.CompilerServices.CallerMemberNameAttribute");
            CultureInfo = compilation.FindType("System.Globalization.CultureInfo");
            InvalidOperationException = compilation.FindType("System.InvalidOperationException");
            InvalidOperationExceptionStringConstructor = InvalidOperationException.Constructors.Single(x => x.Parameters.Count() == 1 && x.Parameters.First().Type == String);

            IAsyncStateMachine                = compilation.FindType("System.Runtime.CompilerServices.IAsyncStateMachine");
            IAsyncStateMachineMoveNext        = IAsyncStateMachine.GetMethodByName("MoveNext");
            IAsyncStateMachineSetStateMachine = IAsyncStateMachine.GetMethodByName("SetStateMachine");
            IEnumerator               = compilation.FindType("System.Collections.IEnumerator");
            IEnumerable               = compilation.FindType("System.Collections.IEnumerable");
            IEnumeratorT              = compilation.FindType("System.Collections.Generic.IEnumerator`1");
            IEnumerableT              = compilation.FindType("System.Collections.Generic.IEnumerable`1");
            IEnumeratorCurrent        = (IPropertySymbol)IEnumerator.GetMembers("Current").Single();
            IEnumeratorMoveNext       = (IMethodSymbol)IEnumerator.GetMembers("MoveNext").Single();
            IEnumeratorReset          = (IMethodSymbol)IEnumerator.GetMembers("Reset").Single();
            IEnumerableGetEnumerator  = (IMethodSymbol)IEnumerable.GetMembers("GetEnumerator").Single();
            IEnumeratorTCurrent       = (IPropertySymbol)IEnumeratorT.GetMembers("Current").Single();
            IEnumerableTGetEnumerator = (IMethodSymbol)IEnumerableT.GetMembers("GetEnumerator").Single();
            YieldIterator             = compilation.FindType("System.YieldIterator`1");
            YieldIteratorClone        = YieldIterator.GetMethodByName("Clone");
            YieldIteratorDoMoveNext   = YieldIterator.GetMethodByName("DoMoveNext");

//            IAutoNotifyPropertyChanged = compilation.FindType("System.Runtime.WootzJs.IAutoNotifyPropertyChanged");
//            NotifyPropertyChanged = IAutoNotifyPropertyChanged.GetMethod("NotifyPropertyChanged");
        }
Exemplo n.º 2
0
//        public NamedTypeSymbol IAutoNotifyPropertyChanged { get; private set; }
//        public MethodSymbol NotifyPropertyChanged { get; private set; }

        public static void Update(Solution solution, Project project, Compilation compilation, ReflectionCache reflectionCache)
        {
            instance = new Context();
            instance.UpdateContext(solution, project, compilation, reflectionCache);
        }
Exemplo n.º 3
0
//        public NamedTypeSymbol IAutoNotifyPropertyChanged { get; private set; }
//        public MethodSymbol NotifyPropertyChanged { get; private set; }

        public static void Update(Solution solution, Project project, Compilation compilation, ReflectionCache reflectionCache)
        {
            Profiler.Time("Updating Context", () =>
            {
                instance = new Context();
                instance.UpdateContext(solution, project, compilation, reflectionCache);
            });
        }
Exemplo n.º 4
0
        private void UpdateContext(Solution solution, Project project, Compilation compilation, ReflectionCache reflectionCache)
        {
            Solution = solution;
            Project = project;
            Compilation = compilation;
            ReflectionCache = reflectionCache;

//            var diagnostics = compilation.GetDiagnostics();
//            var mscorlib = compilation.GetReferencedAssemblySymbol(project.MetadataReferences.First());
//            var typeNames = mscorlib.TypeNames.OrderBy(x => x).ToArray();

            ObjectToString = compilation.ObjectType.GetMembers("ToString").OfType<IMethodSymbol>().Single();
            String = compilation.FindType("System.String");
            SpecialFunctions = compilation.FindType("System.Runtime.WootzJs.SpecialFunctions");
            DefaultOf = SpecialFunctions.GetMethod("DefaultOf");
            Char = compilation.FindType("System.Char");
            Byte = compilation.FindType("System.Byte");
            Int16 = compilation.FindType("System.Int16");
            Int32 = compilation.FindType("System.Int32");
            Int64 = compilation.FindType("System.Int64");
            SByte = compilation.FindType("System.SByte");
            UInt16 = compilation.FindType("System.UInt16");
            UInt32 = compilation.FindType("System.UInt32");
            UInt64 = compilation.FindType("System.UInt64");
            Single = compilation.FindType("System.Single");
            Double = compilation.FindType("System.Double");
            Decimal = compilation.FindType("System.Decimal");
            Exception = compilation.FindType("System.Exception");
            InternalInit = Exception.GetMethodByName("InternalInit");
            Assembly = compilation.FindType("System.Reflection.Assembly");
            AssemblyConstructor = Assembly.InstanceConstructors.Single();
            JsAttributeType = compilation.FindType("System.Runtime.WootzJs.JsAttribute");
            JsCompilerOptionsAttribute = compilation.FindType("System.Runtime.WootzJs.JsCompilerOptionsAttribute");
            PrecedesAttribute = compilation.FindType("System.Runtime.WootzJs.DependsOnAttribute");
            ObjectType = compilation.FindType("System.Object");
            GetType = ObjectType.GetMethod("GetType");
            ObjectReferenceEquals = (IMethodSymbol)ObjectType.GetMembers("ReferenceEquals").Single();
            ObjectCast = (IMethodSymbol)SpecialFunctions.GetMembers("ObjectCast").Single();
            ObjectCreateDelegate = (IMethodSymbol)SpecialFunctions.GetMembers("CreateDelegate").Single();
            TypeType = compilation.FindType("System.Type");
            TypeArray = compilation.CreateArrayTypeSymbol(TypeType);
            TypeConstructor = TypeType.InstanceConstructors.Single();
            TypeInit = (IMethodSymbol)TypeType.GetMembers("Init").Single();
            CreateTypeParameter = (IMethodSymbol)TypeType.GetMembers("CreateTypeParameter").Single();
            TypeIsInstanceOfType = (IMethodSymbol)TypeType.GetMembers("IsInstanceOfType").Single();
            Type_GetTypeFromTypeFunc = (IMethodSymbol)TypeType.GetMembers("_GetTypeFromTypeFunc").Single();
            GetField = TypeType.GetMethod("GetField", String);
            GetProperty = TypeType.GetMethod("GetProperty", String);
            GetMethod = TypeType.GetMethod("GetMethod", String, TypeArray);
            GetConstructor = TypeType.GetMethod("GetConstructor", TypeArray);
            AsExtensionType = compilation.FindType("System.Runtime.WootzJs.AsExtension");
            JsniType = compilation.FindType("System.Runtime.WootzJs.Jsni");
            EnumType = compilation.FindType("System.Enum");
            EnumGetValue = EnumType.GetMethod("GetValue");
            EnumInternalToObject = EnumType.GetMethod("InternalToObject");
            Enumerable = compilation.FindType("System.Collections.IEnumerable");
            EnumerableGeneric = compilation.FindType("System.Collections.Generic.IEnumerable`1");
            Enumerator = compilation.FindType("System.Collections.IEnumerator");
            EnumerableGetEnumerator = (IMethodSymbol)Enumerable.GetMembers("GetEnumerator").Single();
            EnumeratorCurrent = (IPropertySymbol)Enumerator.GetMembers("Current").Single();
            EnumeratorMoveNext = (IMethodSymbol)Enumerator.GetMembers("MoveNext").Single();
            DelegateType = compilation.FindType("System.Delegate");
            DelegateTypeConstructor = DelegateType.InstanceConstructors.Single();
            DelegateTarget = (IPropertySymbol)DelegateType.GetMembers("Target").Single();
            DelegateCombine = DelegateType.GetMembers("Combine").OfType<IMethodSymbol>().Single(x => x.Parameters.Count() == 2 && x.Parameters.All(y => Equals(y.Type, DelegateType)));
            DelegateRemove = DelegateType.GetMembers("Remove").OfType<IMethodSymbol>().Single(x => x.Parameters.Count() == 2 && x.Parameters.All(y => Equals(y.Type, DelegateType)));
            MulticastDelegateType = compilation.FindType("System.MulticastDelegate");
            MulticastDelegateConstructor = MulticastDelegateType.InstanceConstructors.Single(x => x.Parameters.Last().Type.TypeKind == TypeKind.Array);
            NullableType = compilation.FindType("System.Nullable`1");
            CharNullable = NullableType.Construct(Char);
            NullableHasValue = (IPropertySymbol)NullableType.GetMembers("HasValue").Single();
            NullableValue = (IPropertySymbol)NullableType.GetMembers("Value").Single();
            NullableGetValueOrDefault = (IMethodSymbol)NullableType.GetMembers("GetValueOrDefault").Single();
            FieldInfo = compilation.FindType("System.Reflection.FieldInfo");
            MethodInfo = compilation.FindType("System.Reflection.MethodInfo");
            MemberInfo = compilation.FindType("System.Reflection.MemberInfo");
            PropertyInfo = compilation.FindType("System.Reflection.PropertyInfo");
            EventInfo = compilation.FindType("System.Reflection.EventInfo");
            ConstructorInfo = compilation.FindType("System.Reflection.ConstructorInfo");
            Attribute = compilation.FindType("System.Attribute");
            FieldInfoConstructor = FieldInfo.InstanceConstructors.Single();
            MethodInfoConstructor = MethodInfo.InstanceConstructors.Single();
            ParameterInfo = compilation.FindType("System.Reflection.ParameterInfo");
            ParameterInfoConstructor = ParameterInfo.InstanceConstructors.Single();
            PropertyInfoConstructor = PropertyInfo.InstanceConstructors.Single();
            EventInfoConstructor = EventInfo.InstanceConstructors.Single();
            ConstructorInfoConstructor = ConstructorInfo.InstanceConstructors.Single();
            TypeAttributes = compilation.FindType("System.Reflection.TypeAttributes");
            TypeAttributesPublic = (IFieldSymbol)TypeAttributes.GetMembers("Public").Single();
            TypeAttributesNotPublic = (IFieldSymbol)TypeAttributes.GetMembers("NotPublic").Single();
            TypeAttributesNestedPublic = (IFieldSymbol)TypeAttributes.GetMembers("NestedPublic").Single();
            TypeAttributesNestedPrivate = (IFieldSymbol)TypeAttributes.GetMembers("NestedPrivate").Single();
            TypeAttributesNestedFamily = (IFieldSymbol)TypeAttributes.GetMembers("NestedFamily").Single();
            TypeAttributesNestedAssembly = (IFieldSymbol)TypeAttributes.GetMembers("NestedAssembly").Single();
            TypeAttributesNestedFamANDAssem = (IFieldSymbol)TypeAttributes.GetMembers("NestedFamANDAssem").Single();
            TypeAttributesNestedFamORAssem = (IFieldSymbol)TypeAttributes.GetMembers("NestedFamORAssem").Single();
            TypeAttributesAbstract = (IFieldSymbol)TypeAttributes.GetMembers("Abstract").Single();
            TypeAttributesSealed = (IFieldSymbol)TypeAttributes.GetMembers("Sealed").Single();
            TypeAttributesClass = (IFieldSymbol)TypeAttributes.GetMembers("Class").Single();
            TypeAttributesInterface = (IFieldSymbol)TypeAttributes.GetMembers("Interface").Single();
            FieldAttributes = compilation.FindType("System.Reflection.FieldAttributes");
            FieldAttributesPublic = (IFieldSymbol)FieldAttributes.GetMembers("Public").Single();
            FieldAttributesPrivate = (IFieldSymbol)FieldAttributes.GetMembers("Private").Single();
            FieldAttributesFamily = (IFieldSymbol)FieldAttributes.GetMembers("Family").Single();
            FieldAttributesAssembly = (IFieldSymbol)FieldAttributes.GetMembers("Assembly").Single();
            FieldAttributesFamORAssem = (IFieldSymbol)FieldAttributes.GetMembers("FamORAssem").Single();
            FieldAttributesStatic = (IFieldSymbol)FieldAttributes.GetMembers("Static").Single();
            FieldAttributesInitOnly = (IFieldSymbol)FieldAttributes.GetMembers("InitOnly").Single();
            FieldAttributesLiteral = (IFieldSymbol)FieldAttributes.GetMembers("Literal").Single();
            MethodAttributes = compilation.FindType("System.Reflection.MethodAttributes");
            MethodAttributesPublic = (IFieldSymbol)MethodAttributes.GetMembers("Public").Single();
            MethodAttributesPrivate = (IFieldSymbol)MethodAttributes.GetMembers("Private").Single();
            MethodAttributesFamily = (IFieldSymbol)MethodAttributes.GetMembers("Family").Single();
            MethodAttributesAssembly = (IFieldSymbol)MethodAttributes.GetMembers("Assembly").Single();
            MethodAttributesFamORAssem = (IFieldSymbol)MethodAttributes.GetMembers("FamORAssem").Single();
            MethodAttributesStatic = (IFieldSymbol)MethodAttributes.GetMembers("Static").Single();
            ParameterAttributes = compilation.FindType("System.Reflection.ParameterAttributes");
            ParameterAttributesOut = (IFieldSymbol)ParameterAttributes.GetMembers("Out").Single();
            ParameterAttributesHasDefault = (IFieldSymbol)ParameterAttributes.GetMembers("HasDefault").Single();
            ParameterAttributesNone = (IFieldSymbol)ParameterAttributes.GetMembers("None").Single();
            JsFunction = compilation.FindType("System.Runtime.WootzJs.JsFunction");
            IDisposable = compilation.FindType("System.IDisposable");
            IDisposableDispose = (IMethodSymbol)IDisposable.GetMembers("Dispose").Single();
            Expression = compilation.FindType("System.Linq.Expressions.Expression");
            ExpressionGeneric = compilation.FindType("System.Linq.Expressions.Expression`1");
            ExpressionArray = compilation.CreateArrayTypeSymbol(Expression);
            ExpressionType = compilation.FindType("System.Linq.Expressions.ExpressionType");
            ExpressionLambda = compilation.FindType("System.Linq.Expressions.Expression`1");
            ParameterExpression = compilation.FindType("System.Linq.Expressions.ParameterExpression");
            ParameterExpressionArray = compilation.CreateArrayTypeSymbol(ParameterExpression);
            NewExpression = compilation.FindType("System.Linq.Expressions.NewExpression");
            MemberBinding = compilation.FindType("System.Linq.Expressions.MemberBinding");
            MemberBindingArray = compilation.CreateArrayTypeSymbol(MemberBinding);
            ElementInit = compilation.FindType("System.Linq.Expressions.ElementInit");
            ElementInitArray = compilation.CreateArrayTypeSymbol(ElementInit);
            Constant = compilation.FindType("System.Linq.Expressions.ConstantExpression");
            Action = compilation.FindType("System.Action");
            ActionT = compilation.FindType("System.Action`1");
            Func = compilation.FindType("System.Func`1");
            JsObject = compilation.FindType("System.Runtime.WootzJs.JsObject");
            JsString = compilation.FindType("System.Runtime.WootzJs.JsString");
            SafeToString = SpecialFunctions.GetMembers("SafeToString").OfType<IMethodSymbol>().Single();
            Array = compilation.FindType("System.Array");
            INotifyPropertyChanged = compilation.FindType("System.ComponentModel.INotifyPropertyChanged");
            Task = compilation.FindType("System.Threading.Tasks.Task");
            TaskT = compilation.FindType("System.Threading.Tasks.Task`1");
            TaskAwaiter = compilation.FindType("System.Runtime.CompilerServices.TaskAwaiter");
            TaskAwaiterT = compilation.FindType("System.Runtime.CompilerServices.TaskAwaiter`1");
            Nop = compilation.FindType("System.Runtime.CompilerServices.Op").GetMethod("Nothing");
            AsyncVoidMethodBuilder = compilation.FindType("System.Runtime.CompilerServices.AsyncVoidMethodBuilder");
            AsyncVoidMethodBuilderCreate = AsyncVoidMethodBuilder.GetMethod("Create");
            AsyncVoidMethodBuilderStart = AsyncVoidMethodBuilder.GetMethod("Start");
            AsyncTaskMethodBuilder = compilation.FindType("System.Runtime.CompilerServices.AsyncTaskMethodBuilder");
            AsyncTaskMethodBuilderCreate = AsyncTaskMethodBuilder.GetMethod("Create");
            AsyncTaskMethodBuilderStart = AsyncTaskMethodBuilder.GetMethod("Start");
            AsyncTaskTMethodBuilder = compilation.FindType("System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1");
            AsyncTaskTMethodBuilderCreate = AsyncTaskTMethodBuilder.GetMethod("Create");
            AsyncTaskTMethodBuilderStart = AsyncTaskTMethodBuilder.GetMethod("Start");
            CallerMemberNameAttribute = compilation.FindType("System.Runtime.CompilerServices.CallerMemberNameAttribute");
            CultureInfo = compilation.FindType("System.Globalization.CultureInfo");
            InvalidOperationException = compilation.FindType("System.InvalidOperationException");
            InvalidOperationExceptionStringConstructor = InvalidOperationException.Constructors.Single(x => x.Parameters.Count() == 1 && x.Parameters.First().Type == String);

            IAsyncStateMachine = compilation.FindType("System.Runtime.CompilerServices.IAsyncStateMachine");
            IAsyncStateMachineMoveNext = IAsyncStateMachine.GetMethodByName("MoveNext");
            IAsyncStateMachineSetStateMachine = IAsyncStateMachine.GetMethodByName("SetStateMachine");
            IEnumerator = compilation.FindType("System.Collections.IEnumerator");
            IEnumerable = compilation.FindType("System.Collections.IEnumerable");
            IEnumeratorT = compilation.FindType("System.Collections.Generic.IEnumerator`1");
            IEnumerableT = compilation.FindType("System.Collections.Generic.IEnumerable`1");
            IEnumeratorCurrent = (IPropertySymbol)IEnumerator.GetMembers("Current").Single();
            IEnumeratorMoveNext = (IMethodSymbol)IEnumerator.GetMembers("MoveNext").Single();
            IEnumeratorReset = (IMethodSymbol)IEnumerator.GetMembers("Reset").Single();
            IEnumerableGetEnumerator = (IMethodSymbol)IEnumerable.GetMembers("GetEnumerator").Single();
            IEnumeratorTCurrent = (IPropertySymbol)IEnumeratorT.GetMembers("Current").Single();
            IEnumerableTGetEnumerator = (IMethodSymbol)IEnumerableT.GetMembers("GetEnumerator").Single();
            YieldIterator = compilation.FindType("System.YieldIterator`1");
            YieldIteratorClone = YieldIterator.GetMethodByName("Clone");
            YieldIteratorDoMoveNext = YieldIterator.GetMethodByName("DoMoveNext");
            NullPropagation = SpecialFunctions.GetMethod("NullPropagation");

//            IAutoNotifyPropertyChanged = compilation.FindType("System.Runtime.WootzJs.IAutoNotifyPropertyChanged");
//            NotifyPropertyChanged = IAutoNotifyPropertyChanged.GetMethod("NotifyPropertyChanged");
        }
Exemplo n.º 5
0
//        public NamedTypeSymbol IAutoNotifyPropertyChanged { get; private set; }
//        public MethodSymbol NotifyPropertyChanged { get; private set; }

        public static void Update(Solution solution, Project project, Compilation compilation, ReflectionCache reflectionCache)
        {
            Profiler.Time("Updating Context", () =>
            {
                instance = new Context();
                instance.UpdateContext(solution, project, compilation, reflectionCache);
            });
        }