示例#1
0
        protected override bool PostProcessImpl()
        {
            var mainModuleTypes = AssemblyDefinition.MainModule.GetAllTypes().Where(TypeDefinitionExtensions.IsComponentSystem).ToArray();

            bool madeChange = false;

            foreach (var systemType in mainModuleTypes)
            {
                InjectOnCreateForCompiler(systemType);
                madeChange = true;
            }

            foreach (var m in mainModuleTypes.SelectMany(m => m.Methods).ToList())
            {
                LambdaJobDescriptionConstruction[] lambdaJobDescriptionConstructions;
                try
                {
                    lambdaJobDescriptionConstructions = LambdaJobDescriptionConstruction.FindIn(m).ToArray();
                    foreach (var description in lambdaJobDescriptionConstructions)
                    {
                        madeChange = true;
                        Rewrite(m, description, _diagnosticMessages);
                    }
                }
                catch (PostProcessException ppe)
                {
                    AddDiagnostic(ppe.ToDiagnosticMessage(m));
                }
            }

            return(madeChange);
        }
示例#2
0
        protected override bool PostProcessImpl()
        {
            var mainModuleTypes = AssemblyDefinition.MainModule.GetAllTypes().Where(TypeDefinitionExtensions.IsComponentSystem).ToArray();

            bool madeChange = false;

            foreach (var systemType in mainModuleTypes)
            {
                InjectOnCreateForCompiler(systemType);
                madeChange = true;
            }

            foreach (var m in mainModuleTypes.SelectMany(m => m.Methods).ToList())
            {
                LambdaJobDescriptionConstruction[] lambdaJobDescriptionConstructions;
                try
                {
                    lambdaJobDescriptionConstructions = LambdaJobDescriptionConstruction.FindIn(m).ToArray();
                    foreach (var description in lambdaJobDescriptionConstructions)
                    {
                        madeChange = true;
                        var(jobStructForLambdaJob, rewriteDiagnosticMessages) = Rewrite(m, description);
                        _diagnosticMessages.AddRange(rewriteDiagnosticMessages);
                    }
                }
                catch (PostProcessException ppe)
                {
                    AddDiagnostic(ppe.ToDiagnosticMessage(m));
                }
                catch (FoundErrorInUserCodeException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    var seq = m.DebugInformation.SequencePoints.FirstOrDefault();
                    AddDiagnostic(new DiagnosticMessage
                    {
                        MessageData    = $"Unexpected error while post-processing {m.DeclaringType.FullName}:{m.Name}. Please report this error.{Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}",
                        DiagnosticType = DiagnosticType.Error,
                        Line           = seq?.StartLine ?? 0,
                        Column         = seq?.StartColumn ?? 0,
                    });
                }
            }

            return(madeChange);
        }
        protected override bool PostProcessImpl(TypeDefinition[] componentSystemTypes)
        {
            bool madeChange = false;

            foreach (var m in componentSystemTypes.SelectMany(m => m.Methods).ToList())
            {
                LambdaJobDescriptionConstruction[] lambdaJobDescriptionConstructions;
                try
                {
                    lambdaJobDescriptionConstructions = LambdaJobDescriptionConstruction.FindIn(m).ToArray();
                    foreach (var description in lambdaJobDescriptionConstructions)
                    {
                        madeChange = true;
                        var(_, rewriteDiagnosticMessages) = Rewrite(m, description);
                        _diagnosticMessages.AddRange(rewriteDiagnosticMessages);
                    }
                }
                catch (FoundErrorInUserCodeException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    var seq = m.DebugInformation.SequencePoints.FirstOrDefault();
                    AddDiagnostic(new DiagnosticMessage
                    {
                        MessageData    = $"Unexpected error while post-processing lambdas in {m.DeclaringType.FullName}:{m.Name}. Please report this error.{Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}",
                        DiagnosticType = DiagnosticType.Error,
                        Line           = seq?.StartLine ?? 0,
                        Column         = seq?.StartColumn ?? 0,
                    });
                }
            }

            return(madeChange);
        }