public void Handle()

in src/Core/Compiling/Policy/ForwardRequestCompiler.cs [30:89]


    public void Handle(ICompilationContext context, InvocationExpressionSyntax node)
    {
        if (node.ArgumentList.Arguments.Count > 1)
        {
            context.Report(Diagnostic.Create(
                CompilationErrors.ArgumentCountMissMatchForPolicy,
                node.ArgumentList.GetLocation(),
                "forward-request"
                ));
            return;
        }

        var element = new XElement("forward-request");
        if (node.ArgumentList.Arguments.Count == 1)
        {
            if (node.ArgumentList.Arguments[0].Expression is not ObjectCreationExpressionSyntax config)
            {
                context.Report(Diagnostic.Create(
                    CompilationErrors.PolicyArgumentIsNotAnObjectCreation,
                    node.ArgumentList.Arguments[0].Expression.GetLocation(),
                    "forward-request"));
                return;
            }

            var initializer = config.Process(context);
            if (initializer.Type != nameof(ForwardRequestConfig))
            {
                context.Report(Diagnostic.Create(
                    CompilationErrors.PolicyArgumentIsNotOfRequiredType,
                    config.GetLocation(),
                    "forward-request",
                    nameof(ForwardRequestConfig)
                ));
                return;
            }

            if (initializer.NamedValues is not null)
            {
                if (initializer.NamedValues.ContainsKey(nameof(ForwardRequestConfig.Timeout))
                    && initializer.NamedValues.ContainsKey(nameof(ForwardRequestConfig.TimeoutMs)))
                {
                    context.Report(Diagnostic.Create(
                        CompilationErrors.OnlyOneOfTwoShouldBeDefined,
                        config.GetLocation(),
                        "forward-request",
                        nameof(ForwardRequestConfig.Timeout),
                        nameof(ForwardRequestConfig.TimeoutMs)
                    ));
                }

                foreach ((string key, InitializerValue value) in initializer.NamedValues)
                {
                    var name = FieldToAttribute.GetValueOrDefault(key, key);
                    element.Add(new XAttribute(name, value.Value!));
                }
            }
        }

        context.AddPolicy(element);
    }