Esempio n. 1
0
        public void Execute(GeneratorExecutionContext context)
        {
            DependenciesInitializer.Init(context);

            if (!DesignTimeHelper.IsDesignTime(context))
            {
                _bindingsPaths    = context.GetMSBuildPropertyValue("TSBindingsPath")?.ToString();
                _sourceAssemblies = context.GetMSBuildItems("TSBindingAssemblySource").Select(i => i.Identity).ToArray();

                if (!string.IsNullOrEmpty(_bindingsPaths))
                {
                    _stringSymbol         = context.Compilation.GetTypeByMetadataName("System.String");
                    _intSymbol            = context.Compilation.GetTypeByMetadataName("System.Int32");
                    _floatSymbol          = context.Compilation.GetTypeByMetadataName("System.Single");
                    _doubleSymbol         = context.Compilation.GetTypeByMetadataName("System.Double");
                    _byteSymbol           = context.Compilation.GetTypeByMetadataName("System.Byte");
                    _shortSymbol          = context.Compilation.GetTypeByMetadataName("System.Int16");
                    _intPtrSymbol         = context.Compilation.GetTypeByMetadataName("System.IntPtr");
                    _boolSymbol           = context.Compilation.GetTypeByMetadataName("System.Boolean");
                    _longSymbol           = context.Compilation.GetTypeByMetadataName("System.Int64");
                    _structLayoutSymbol   = context.Compilation.GetTypeByMetadataName(typeof(System.Runtime.InteropServices.StructLayoutAttribute).FullName);
                    _interopMessageSymbol = context.Compilation.GetTypeByMetadataName("Uno.Foundation.Interop.TSInteropMessageAttribute");

                    var modules = from ext in context.Compilation.ExternalReferences
                                  let sym = context.Compilation.GetAssemblyOrModuleSymbol(ext) as IAssemblySymbol
                                            where _sourceAssemblies.Contains(sym.Name)
                                            from module in sym.Modules
                                            select module;

                    modules = modules.Concat(context.Compilation.SourceModule);

                    GenerateTSMarshallingLayouts(modules);
                }
            }
        }
Esempio n. 2
0
        private void RegisterContainer(IServiceCollection services)
        {
            container = DependenciesInitializer.Init();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddSingleton <IControllerActivator>(
                new SimpleInjectorControllerActivator(container));
            services.AddSingleton <IViewComponentActivator>(
                new SimpleInjectorViewComponentActivator(container));
            services.EnableSimpleInjectorCrossWiring(container);

            services.UseSimpleInjectorAspNetRequestScoping(container);


            services.AddSimpleInjector(container, options =>
            {
                // AddAspNetCore() wraps web requests in a Simple Injector scope.
                options.AddAspNetCore()
                // Ensure activation of a specific framework type to be created by
                // Simple Injector instead of the built-in configuration system.
                .AddControllerActivation()
                .AddViewComponentActivation()
                .AddPageModelActivation()
                .AddTagHelperActivation();
            });
        }
Esempio n. 3
0
        public void Execute(GeneratorExecutionContext context)
        {
            DependenciesInitializer.Init(context);

            if (
                !DesignTimeHelper.IsDesignTime(context) &&
                context.GetMSBuildPropertyValue("Configuration") == "Debug" &&
                IsRemoteControlClientInstalled(context) &&
                IsApplication(context))
            {
                var sb = new IndentedStringBuilder();

                sb.AppendLineInvariant("// <auto-generated>");
                sb.AppendLineInvariant("// ***************************************************************************************");
                sb.AppendLineInvariant("// This file has been generated by the package Uno.UI.RemoteControl - for Xaml Hot Reload.");
                sb.AppendLineInvariant("// Documentation: https://platform.uno/docs/articles/features/working-with-xaml-hot-reload.html");
                sb.AppendLineInvariant("// ***************************************************************************************");
                sb.AppendLineInvariant("// </auto-generated>");
                sb.AppendLineInvariant("// <autogenerated />");
                sb.AppendLineInvariant("#pragma warning disable // Ignore code analysis warnings");

                sb.AppendLineInvariant("");

                BuildEndPointAttribute(context, sb);
                BuildSearchPaths(context, sb);

                context.AddSource("RemoteControl", sb.ToString());
            }
        }
Esempio n. 4
0
        public void Execute(GeneratorExecutionContext context)
        {
            DependenciesInitializer.Init(context);

            // No initialization required for this one
            //if (!Process.GetCurrentProcess().ProcessName.Equals("devenv", StringComparison.OrdinalIgnoreCase))
            {
                // Debugger.Launch();
            }

            var gen = new XamlCodeGeneration(context);

            if (PlatformHelper.IsValidPlatform(context))
            {
                var genereratedTrees = gen.Generate();

                foreach (var tree in genereratedTrees)
                {
                    context.AddSource(tree.Key, tree.Value);

                    // Uncomment to output the generated files to a separate folder
                    // var intermediatePath = context.GetMSBuildPropertyValue("IntermediateOutputPath");
                    // var path = Path.Combine(intermediatePath, "generated");
                    // Directory.CreateDirectory(path);
                    // File.WriteAllText(Path.Combine(path, tree.Key), tree.Value);
                }
            }
        }
Esempio n. 5
0
 public void Execute(GeneratorExecutionContext context)
 {
     DependenciesInitializer.Init(context);
     if (PlatformHelper.IsValidPlatform(context))
     {
         var visitor = new SerializationMethodsGenerator(context);
         visitor.Visit(context.Compilation.SourceModule);
     }
 }
Esempio n. 6
0
        public void Execute(GeneratorExecutionContext context)
        {
            if (!DesignTimeHelper.IsDesignTime(context))
            {
                DependenciesInitializer.Init(context);

                var visitor = new SerializationMethodsGenerator(context);
                visitor.Visit(context.Compilation.SourceModule);
            }
        }
Esempio n. 7
0
        private void RegisterContainer(IServiceCollection services)
        {
            container = DependenciesInitializer.Init();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddSingleton <IControllerActivator>(
                new SimpleInjectorControllerActivator(container));
            services.AddSingleton <IViewComponentActivator>(
                new SimpleInjectorViewComponentActivator(container));
            services.EnableSimpleInjectorCrossWiring(container);
            services.UseSimpleInjectorAspNetRequestScoping(container);
        }
        public void Execute(GeneratorExecutionContext context)
        {
            DependenciesInitializer.Init(context);

            try
            {
                if (PlatformHelper.IsValidPlatform(context) &&
                    !DesignTimeHelper.IsDesignTime(context))
                {
                    if (IsApplication(context))
                    {
                        _defaultNamespace   = context.GetMSBuildPropertyValue("RootNamespace");
                        _namedSymbolsLookup = context.Compilation.GetSymbolNameLookup();

                        _bindableAttributeSymbol  = FindBindableAttributes(context);
                        _dependencyPropertySymbol = context.Compilation.GetTypeByMetadataName(XamlConstants.Types.DependencyProperty);

                        _objectSymbol             = context.Compilation.GetTypeByMetadataName("System.Object");
                        _javaObjectSymbol         = context.Compilation.GetTypeByMetadataName("Java.Lang.Object");
                        _nsObjectSymbol           = context.Compilation.GetTypeByMetadataName("Foundation.NSObject");
                        _stringSymbol             = context.Compilation.GetTypeByMetadataName("System.String");
                        _nonBindableSymbol        = context.Compilation.GetTypeByMetadataName("Windows.UI.Xaml.Data.NonBindableAttribute");
                        _resourceDictionarySymbol = context.Compilation.GetTypeByMetadataName("Windows.UI.Xaml.ResourceDictionary");
                        _currentModule            = context.Compilation.SourceModule;

                        AnalyzerSuppressions = new string[0];

                        var modules = from ext in context.Compilation.ExternalReferences
                                      let sym = context.Compilation.GetAssemblyOrModuleSymbol(ext) as IAssemblySymbol
                                                where sym != null
                                                from module in sym.Modules
                                                select module;

                        modules = modules.Concat(context.Compilation.SourceModule);

                        context.AddSource("BindableMetadata", GenerateTypeProviders(modules));
                    }
                }
            }
            catch (Exception e)
            {
                var message = e.Message + e.StackTrace;

                if (e is AggregateException)
                {
                    message = (e as AggregateException).InnerExceptions.Select(ex => ex.Message + e.StackTrace).JoinBy("\r\n");
                }

                this.Log().Error("Failed to generate type providers.", new Exception("Failed to generate type providers." + message, e));
            }
        }
Esempio n. 9
0
        public void Execute(GeneratorExecutionContext context)
        {
            DependenciesInitializer.Init(context);

            // No initialization required for this one
            //if (!Process.GetCurrentProcess().ProcessName.Equals("devenv", StringComparison.OrdinalIgnoreCase))
            //{
            //	Debugger.Launch();
            //}

            var gen = new XamlCodeGeneration(context);

            if (PlatformHelper.IsValidPlatform(context))
            {
                var genereratedTrees = gen.Generate();

                foreach (var tree in genereratedTrees)
                {
                    context.AddSource(tree.Key, tree.Value);
                }
            }
        }
Esempio n. 10
0
 public void Initialize(GeneratorInitializationContext context)
 {
     DependenciesInitializer.Init();
 }
Esempio n. 11
0
 public void Initialize(GeneratorInitializationContext context)
 {
     // Debugger.Launch();
     // No initialization required for this one
     DependenciesInitializer.Init();
 }