< Summary - CoreWCF Coverage — PR #1766

Line coverage
96%
Covered lines: 244
Uncovered lines: 8
Coverable lines: 252
Total lines: 587
Line coverage: 96.8%
Branch coverage
93%
Covered branches: 112
Total branches: 120
Branch coverage: 93.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.BuildTools/src/OperationInvokerGenerator.Emitter.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Collections.Generic;
 5using System.Text;
 6using Microsoft.CodeAnalysis;
 7using Microsoft.CodeAnalysis.CSharp;
 8using Microsoft.CodeAnalysis.Text;
 9
 10namespace CoreWCF.BuildTools;
 11
 12public sealed partial class OperationInvokerGenerator
 13{
 14    private sealed class Emitter
 15    {
 16        private readonly StringBuilder _builder;
 17        private readonly OperationInvokerSourceGenerationContext _sourceGenerationContext;
 18        private readonly SourceGenerationSpec _generationSpec;
 19
 20        /// <summary>
 21        /// SymbolDisplayFormat that excludes nullable annotations to match reflection-based key generation.
 22        /// Reflection-based MethodInfo does not expose nullable reference type annotations, so we need to
 23        /// exclude them from the generated key to ensure the source generator key matches the runtime key.
 24        /// This prevents PlatformNotSupportedException when UseGeneratedOperationInvokers is enabled.
 25        /// </summary>
 126        private static readonly SymbolDisplayFormat s_methodDisplayFormat = new SymbolDisplayFormat(
 127            globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
 128            typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
 129            genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
 130            memberOptions: SymbolDisplayMemberOptions.IncludeParameters | SymbolDisplayMemberOptions.IncludeContainingTy
 131            parameterOptions: SymbolDisplayParameterOptions.IncludeType | SymbolDisplayParameterOptions.IncludeParamsRef
 132            miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes);
 33
 34        /// <summary>
 35        /// SymbolDisplayFormat for emitting type references in generated code. Mirrors the default
 36        /// CSharpErrorMessageFormat but strips nullable reference type annotations because the generated
 37        /// file is wrapped in a '#nullable disable' context. Emitting NRT annotations like 'string?' under
 38        /// '#nullable disable' produces CS8669 warnings (see issue #1712). Nullable value types such as
 39        /// 'int?' are unaffected because they are System.Nullable&lt;T&gt; rather than NRT annotations.
 40        /// </summary>
 141        private static readonly SymbolDisplayFormat s_typeDisplayFormat = SymbolDisplayFormat.CSharpErrorMessageFormat
 142            .RemoveMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier);
 43
 5244        public Emitter(in OperationInvokerSourceGenerationContext sourceGenerationContext, in SourceGenerationSpec gener
 45        {
 5246            _sourceGenerationContext = sourceGenerationContext;
 5247            _generationSpec = generationSpec;
 5248            _builder = new StringBuilder();
 5249        }
 50
 51        public void Emit()
 52        {
 5253            if (_generationSpec.OperationContractSpecs.Length == 0)
 54            {
 055                return;
 56            }
 5257            _builder.Clear();
 5258            _builder.AppendLine($$"""
 5259                                  // <auto-generated>
 5260                                  // Generated by the CoreWCF.BuildTools.OperationInvokerGenerator source generator. DO 
 5261                                  // </auto-generated>
 5262                                  #nullable disable
 5263                                  using System;
 5264                                  using System.Threading.Tasks;
 5265                                  namespace System.Runtime.CompilerServices
 5266                                  {
 5267                                      [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
 5268                                      file sealed class ModuleInitializerAttribute : Attribute { }
 5269                                  }
 5270                                  """);
 5271            int i = 0;
 22472            foreach (var operationContractSpec in _generationSpec.OperationContractSpecs)
 73            {
 6074                EmitOperationContract(operationContractSpec, i);
 6075                i++;
 76            }
 77
 5278            var indentor = new Indentor();
 5279            _builder.AppendLine($$"""
 5280                                  namespace CoreWCF.Dispatcher
 5281                                  {
 5282                                      file sealed class OperationInvokerModuleInitializer
 5283                                      {
 5284                                  """);
 5285            indentor.Increment();
 5286            indentor.Increment();
 87
 5288            _builder.AppendLine($"{indentor}[System.Runtime.CompilerServices.ModuleInitializer]");
 5289            _builder.AppendLine($"{indentor}internal static void RegisterOperationInvokers()");
 5290            _builder.AppendLine($"{indentor}{{");
 5291            indentor.Increment();
 22492            for (int j = 0; j < i; j++)
 93            {
 6094                _builder.AppendLine($"{indentor}{GetOperationInvokerTypeName(j)}.RegisterOperationInvoker();");
 95            }
 5296            indentor.Decrement();
 5297            _builder.AppendLine($"{indentor}}}");
 5298            indentor.Decrement();
 5299            _builder.AppendLine($"{indentor}}}");
 52100            indentor.Decrement();
 52101            _builder.AppendLine($"{indentor}}}");
 52102            _builder.AppendLine("#nullable restore");
 103
 52104            string sourceText = _builder.ToString();
 52105            _sourceGenerationContext.AddSource("OperationInvoker.g.cs", SourceText.From(sourceText, Encoding.UTF8, Sourc
 52106        }
 107
 108        private void EmitOperationContract(OperationContractSpec operationContractSpec, int index)
 109        {
 60110            var indentor = new Indentor();
 60111            string operationInvokerTypeName = GetOperationInvokerTypeName(index);
 60112            string escapedMethodName = EscapeIdentifier(operationContractSpec.Method!.Name);
 60113            _builder.AppendLine($$"""
 60114                                  namespace CoreWCF.Dispatcher
 60115                                  {
 60116                                      // This class is used to invoke the method {{operationContractSpec.Method.ToDispla
 60117                                      file sealed class {{operationInvokerTypeName}} : CoreWCF.Dispatcher.IOperationInvo
 60118                                      {
 60119                                  """);
 60120            indentor.Increment();
 60121            indentor.Increment();
 122
 60123            INamedTypeSymbol? returnTypeSymbol = operationContractSpec.Method!.ReturnType as INamedTypeSymbol;
 60124            bool isGenericTaskReturnType = returnTypeSymbol != null &&
 60125                                           returnTypeSymbol.IsGenericType &&
 60126                                           returnTypeSymbol.ConstructUnboundGenericType().ToDisplayString() == "System.T
 60127            bool isTaskReturnType = operationContractSpec.Method.ReturnType.ToDisplayString() == "System.Threading.Tasks
 60128            bool isAsync = isGenericTaskReturnType || isTaskReturnType;
 129
 60130            string asyncString = isAsync ? "async " : string.Empty;
 60131            _builder.AppendLine($"{indentor}public { asyncString }ValueTask<(object returnValue, object[] outputs)> Invo
 60132            _builder.AppendLine($"{indentor}{{");
 60133            indentor.Increment();
 134
 60135            int inputParameterCount = 0;
 60136            int outputParameterCount = 0;
 137
 60138            List<(int, int, IParameterSymbol)> outputParams = new();
 60139            int i = 0;
 60140            List<string> invocationParams = new();
 336141            foreach (var parameter in operationContractSpec.Method.Parameters)
 142            {
 108143                _builder.AppendLine($"{indentor}{parameter.Type.ToDisplayString(s_typeDisplayFormat)} p{i};");
 108144                if (FlowsIn(parameter))
 145                {
 88146                    _builder.AppendLine($"{indentor}p{i} = inputs[{inputParameterCount}] == null ? default({parameter.Ty
 88147                    inputParameterCount++;
 148                }
 149
 108150                if (FlowOut(parameter))
 151                {
 40152                    outputParams.Add((outputParameterCount, i, parameter));
 40153                    outputParameterCount++;
 154                }
 155
 108156                invocationParams.Add($"{GetRefKind(parameter)}p{i}");
 108157                i++;
 158            }
 159
 60160            if (isAsync)
 161            {
 8162                if (isTaskReturnType)
 163                {
 4164                    _builder.AppendLine($"{indentor}await (({operationContractSpec.Method.ContainingType.ToDisplayString
 165                }
 166                else
 167                {
 4168                    _builder.AppendLine($"{indentor}var result = await (({operationContractSpec.Method.ContainingType.To
 169                }
 170            }
 171            else
 172            {
 52173                if (operationContractSpec.Method.ReturnsVoid)
 174                {
 4175                    _builder.AppendLine($"{indentor}(({operationContractSpec.Method.ContainingType.ToDisplayString(s_typ
 176                }
 177                else
 178                {
 48179                    _builder.AppendLine($"{indentor}var result = (({operationContractSpec.Method.ContainingType.ToDispla
 180                }
 181            }
 182
 60183            _builder.AppendLine($"{indentor}var outputs = AllocateOutputs();");
 184
 200185            foreach (var (ouputIndex, parameterIndex, parameter) in outputParams)
 186            {
 40187                _builder.AppendLine($"{indentor}outputs[{ouputIndex}] = p{parameterIndex};");
 188            }
 189
 60190            if (isAsync)
 191            {
 8192                if (isTaskReturnType)
 193                {
 4194                    _builder.AppendLine($"{indentor}return (null, outputs);");
 195                }
 196                else
 197                {
 4198                    _builder.AppendLine($"{indentor}return (result, outputs);");
 199                }
 200            }
 201            else
 202            {
 52203                if (operationContractSpec.Method.ReturnsVoid)
 204                {
 4205                    _builder.AppendLine($"{indentor}return new ValueTask<(object, object[])>((null, outputs));");
 206                }
 207                else
 208                {
 48209                    _builder.AppendLine($"{indentor}return new ValueTask<(object, object[])>((result, outputs));");
 210                }
 211            }
 212
 60213            indentor.Decrement();
 60214            _builder.AppendLine($"{indentor}}}");
 60215            _builder.AppendLine();
 60216            _builder.Append($"{indentor}public object[] AllocateInputs() => ");
 60217            if (inputParameterCount == 0)
 218            {
 0219                _builder.AppendLine("Array.Empty<object>();");
 220            }
 221            else
 222            {
 60223                _builder.AppendLine($"new object[{inputParameterCount}];");
 224            }
 60225            _builder.AppendLine();
 60226            _builder.Append($"{indentor}private object[] AllocateOutputs() => ");
 60227            if (outputParameterCount == 0)
 228            {
 40229                _builder.AppendLine("Array.Empty<object>();");
 230            }
 231            else
 232            {
 20233                _builder.AppendLine($"new object[{outputParameterCount}];");
 234            }
 60235            _builder.AppendLine();
 236
 60237            _builder.Append($"{indentor}internal static void RegisterOperationInvoker() => ");
 60238            _builder.AppendLine($"CoreWCF.Dispatcher.DispatchOperationRuntimeHelpers.RegisterOperationInvoker(\"{operati
 60239            indentor.Decrement();
 60240            _builder.AppendLine($"{indentor}}}");
 241
 60242            indentor.Decrement();
 60243            _builder.AppendLine($"{indentor}}}");
 244
 245
 60246        }
 247
 120248        private static string GetOperationInvokerTypeName(int index) => $"OperationInvoker{index}";
 249
 250        private static string EscapeIdentifier(string identifier)
 251        {
 60252            return SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None ||
 60253                   SyntaxFacts.GetContextualKeywordKind(identifier) != SyntaxKind.None
 60254                ? "@" + identifier
 60255                : identifier;
 256        }
 257
 258        private static bool FlowsIn(IParameterSymbol parameterSymbol)
 259        {
 108260            return parameterSymbol.RefKind == RefKind.In || parameterSymbol.RefKind == RefKind.Ref || parameterSymbol.Re
 261        }
 262
 263        private static bool FlowOut(IParameterSymbol parameterSymbol)
 264        {
 108265            return parameterSymbol.RefKind == RefKind.Out || parameterSymbol.RefKind == RefKind.Ref;
 266        }
 267
 268        private static string GetRefKind(IParameterSymbol parameterSymbol)
 269        {
 108270            return parameterSymbol.RefKind switch
 108271            {
 20272                RefKind.Ref => "ref ",
 20273                RefKind.Out => "out ",
 68274                _ => string.Empty,
 108275            };
 276        }
 277    }
 278}

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.BuildTools/src/OperationInvokerGenerator.OperationContractSpec.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using Microsoft.CodeAnalysis;
 5
 6namespace CoreWCF.BuildTools;
 7
 8public sealed partial class OperationInvokerGenerator
 9{
 10    internal readonly record struct OperationContractSpec(IMethodSymbol? Method)
 11    {
 58412        public IMethodSymbol? Method { get; } = Method;
 13    }
 14}

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.BuildTools/src/OperationInvokerGenerator.Parser.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Collections.Immutable;
 7using System.Linq;
 8using Microsoft.CodeAnalysis;
 9using Microsoft.CodeAnalysis.CSharp;
 10using Microsoft.CodeAnalysis.CSharp.Syntax;
 11
 12namespace CoreWCF.BuildTools;
 13
 14public sealed partial class OperationInvokerGenerator
 15{
 16    private sealed class Parser
 17    {
 118        private static readonly SymbolDisplayFormat s_methodDisplayFormat = new SymbolDisplayFormat(
 119            globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
 120            typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
 121            genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
 122            memberOptions: SymbolDisplayMemberOptions.IncludeParameters | SymbolDisplayMemberOptions.IncludeContainingTy
 123            parameterOptions: SymbolDisplayParameterOptions.IncludeType | SymbolDisplayParameterOptions.IncludeParamsRef
 124            miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes);
 25
 26        private readonly Compilation _compilation;
 27        private readonly OperationInvokerSourceGenerationContext _context;
 28        private readonly INamedTypeSymbol? _sSMOperationContractSymbol;
 29        private readonly INamedTypeSymbol? _coreWCFOperationContractSymbol;
 30        private readonly INamedTypeSymbol? _sSMServiceContractSymbol;
 31        private readonly INamedTypeSymbol? _coreWCFServiceContractSymbol;
 32
 7633        public Parser(Compilation compilation, in OperationInvokerSourceGenerationContext context)
 34        {
 7635                _compilation = compilation;
 7636                _context = context;
 37
 7638                _sSMOperationContractSymbol = _compilation.GetTypeByMetadataName("System.ServiceModel.OperationContractA
 7639                _coreWCFOperationContractSymbol = _compilation.GetTypeByMetadataName("CoreWCF.OperationContractAttribute
 7640                _sSMServiceContractSymbol = _compilation.GetTypeByMetadataName("System.ServiceModel.ServiceContractAttri
 7641                _coreWCFServiceContractSymbol = _compilation.GetTypeByMetadataName("CoreWCF.ServiceContractAttribute");
 7642            }
 43
 44        public SourceGenerationSpec GetGenerationSpec(ImmutableArray<InterfaceDeclarationSyntax> interfaceDeclarationSyn
 45        {
 7646                var builder = ImmutableArray.CreateBuilder<OperationContractSpec>();
 7647                HashSet<string> emittedOperations = new(StringComparer.Ordinal);
 48
 7649                var serviceContracts = (from interfaceDeclarationSyntax in interfaceDeclarationSyntaxes
 9650                    let semanticModel = _compilation.GetSemanticModel(interfaceDeclarationSyntax.SyntaxTree)
 9651                    let symbol = semanticModel.GetDeclaredSymbol(interfaceDeclarationSyntax)
 9652                    where symbol is not null
 9653                    let serviceContract = symbol
 9654                    where serviceContract.GetOneAttributeOf(_sSMServiceContractSymbol, _coreWCFServiceContractSymbol) is
 9655                    where !HasOpenGenericContext(serviceContract)
 7256                    where !serviceContract.IsPrivate()
 14057                    select serviceContract).ToImmutableArray();
 58
 28059                foreach (INamedTypeSymbol serviceContract in serviceContracts)
 60                {
 26461                    foreach (IMethodSymbol operationContract in GetOperationContracts(serviceContract))
 62                    {
 6863                        string operationKey = operationContract.ToDisplayString(s_methodDisplayFormat);
 6864                        if (emittedOperations.Add(operationKey))
 65                        {
 6066                            builder.Add(new OperationContractSpec(operationContract));
 67                        }
 68                    }
 69                }
 70
 7671                ImmutableArray<OperationContractSpec> operationContractSpecs = builder.ToImmutable();
 72
 7673                if (operationContractSpecs.IsEmpty)
 74                {
 2475                    return SourceGenerationSpec.None;
 76                }
 77
 5278                return new SourceGenerationSpec(operationContractSpecs);
 79            }
 80
 81        private IEnumerable<IMethodSymbol> GetOperationContracts(INamedTypeSymbol serviceContract)
 82        {
 30483            foreach (INamedTypeSymbol inheritedServiceContract in EnumerateServiceContracts(serviceContract))
 84            {
 32085                foreach (IMethodSymbol method in inheritedServiceContract.GetMembers().OfType<IMethodSymbol>())
 86                {
 7287                    if (method.GetOneAttributeOf(_sSMOperationContractSymbol, _coreWCFOperationContractSymbol) is null)
 88                    {
 89                        continue;
 90                    }
 91
 7292                    IMethodSymbol operationContract = serviceContract.FindImplementationForInterfaceMember(method) as IM
 7293                    if (HasOpenGenericContext(operationContract) || operationContract.IsPrivate())
 94                    {
 95                        continue;
 96                    }
 97
 6898                    yield return operationContract;
 99                }
 100            }
 64101        }
 102
 103        private IEnumerable<INamedTypeSymbol> EnumerateServiceContracts(INamedTypeSymbol serviceContract)
 104        {
 64105            yield return serviceContract;
 106
 176107            foreach (INamedTypeSymbol inheritedInterface in serviceContract.AllInterfaces)
 108            {
 24109                if (inheritedInterface.GetOneAttributeOf(_sSMServiceContractSymbol, _coreWCFServiceContractSymbol) is no
 110                {
 24111                    yield return inheritedInterface;
 112                }
 113            }
 64114        }
 115
 116        private static bool HasOpenGenericContext(IMethodSymbol method)
 117        {
 72118            if (method.TypeParameters.Length > 0)
 119            {
 4120                return true;
 121            }
 122
 68123            return HasOpenGenericContext(method.ContainingType);
 124        }
 125
 126        private static bool HasOpenGenericContext(INamedTypeSymbol? containingType)
 127        {
 460128            for (; containingType != null; containingType = containingType.ContainingType)
 129            {
 172130                if (IsOpenGenericType(containingType))
 131                {
 24132                    return true;
 133                }
 134            }
 135
 140136            return false;
 137        }
 138
 139        private static bool IsOpenGenericType(INamedTypeSymbol type)
 140        {
 172141            return type.IsGenericType && type.TypeArguments.Any(ContainsTypeParameter);
 142        }
 143
 144        private static bool ContainsTypeParameter(ITypeSymbol type)
 145        {
 64146            if (type.TypeKind == TypeKind.TypeParameter)
 147            {
 24148                return true;
 149            }
 150
 40151            if (type is IArrayTypeSymbol arrayType)
 152            {
 0153                return ContainsTypeParameter(arrayType.ElementType);
 154            }
 155
 40156            if (type is IPointerTypeSymbol pointerType)
 157            {
 0158                return ContainsTypeParameter(pointerType.PointedAtType);
 159            }
 160
 40161            return type is INamedTypeSymbol namedType
 40162                   && namedType.IsGenericType
 40163                   && namedType.TypeArguments.Any(ContainsTypeParameter);
 164        }
 165
 4388166        internal static bool IsSyntaxTargetForGeneration(SyntaxNode node) => node is InterfaceDeclarationSyntax interfac
 4388167                                                                             && interfaceDeclarationSyntax.AttributeList
 168
 169        internal static InterfaceDeclarationSyntax? GetSemanticTargetForGeneration(GeneratorSyntaxContext context)
 170        {
 100171                var interfaceDeclarationSyntax = (InterfaceDeclarationSyntax)context.Node;
 300172                foreach (var attributeList in interfaceDeclarationSyntax.AttributeLists)
 173                {
 300174                    foreach (var attribute in attributeList.Attributes)
 175                    {
 100176                        var attributeSymbol = context.SemanticModel.GetSymbolInfo(attribute).Symbol as IMethodSymbol;
 100177                        if (attributeSymbol == null)
 178                        {
 179                            continue;
 180                        }
 181
 100182                        var attributeContainingTypeSymbol = attributeSymbol.ContainingType;
 100183                        var fullName = attributeContainingTypeSymbol.ToDisplayString();
 184
 100185                        if (fullName == "CoreWCF.ServiceContractAttribute" || fullName == "System.ServiceModel.ServiceCo
 186                        {
 100187                            return interfaceDeclarationSyntax;
 188                        }
 189                    }
 190                }
 191
 0192                return null;
 193            }
 194    }
 195}

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.BuildTools/src/OperationInvokerGenerator.Roslyn3.11.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Collections.Generic;
 5using System.Collections.Immutable;
 6using Microsoft.CodeAnalysis;
 7using Microsoft.CodeAnalysis.CSharp.Syntax;
 8using Microsoft.CodeAnalysis.Text;
 9
 10namespace CoreWCF.BuildTools
 11{
 12    [Generator(LanguageNames.CSharp)]
 13    public sealed partial class OperationInvokerGenerator : ISourceGenerator
 14    {
 15        public void Initialize(GeneratorInitializationContext context)
 16        {
 16017            context.RegisterForSyntaxNotifications(static () => new SyntaxContextReceiver());
 8018        }
 19
 20        public void Execute(GeneratorExecutionContext executionContext)
 21        {
 8022            bool enableOperationInvokerGenerator = executionContext.AnalyzerConfigOptions.GlobalOptions
 8023                .TryGetValue("build_property.EnableCoreWCFOperationInvokerGenerator", out string? enableSourceGenerator)
 8024                && enableSourceGenerator == "true";
 25
 8026            if (!enableOperationInvokerGenerator)
 27            {
 428                return;
 29            }
 30
 7631            if (executionContext.SyntaxContextReceiver is not SyntaxContextReceiver receiver || receiver.InterfaceDeclar
 32            {
 33                // nothing to do yet
 034                return;
 35            }
 36
 7637            OperationInvokerSourceGenerationContext context = new(executionContext);
 7638            Parser parser = new(executionContext.Compilation, context);
 7639            SourceGenerationSpec spec = parser.GetGenerationSpec(receiver.InterfaceDeclarationSyntaxList.ToImmutableArra
 7640            if (spec != SourceGenerationSpec.None)
 41            {
 5242                Emitter emitter = new(context, spec);
 5243                emitter.Emit();
 44            }
 7645        }
 46
 47        private sealed class SyntaxContextReceiver : ISyntaxContextReceiver
 48        {
 33249            public List<InterfaceDeclarationSyntax>? InterfaceDeclarationSyntaxList { get; private set; }
 50
 51            public void OnVisitSyntaxNode(GeneratorSyntaxContext context)
 52            {
 438853                if (Parser.IsSyntaxTargetForGeneration(context.Node))
 54                {
 10055                    InterfaceDeclarationSyntax? interfaceDeclarationSyntax = Parser.GetSemanticTargetForGeneration(conte
 10056                    if (interfaceDeclarationSyntax != null)
 57                    {
 10058                        (InterfaceDeclarationSyntaxList ??= new List<InterfaceDeclarationSyntax>()).Add(interfaceDeclara
 59                    }
 60                }
 438861            }
 62        }
 63
 64        internal readonly struct OperationInvokerSourceGenerationContext
 65        {
 66            private readonly GeneratorExecutionContext _context;
 67
 68            public OperationInvokerSourceGenerationContext(GeneratorExecutionContext context)
 69            {
 7670                _context = context;
 7671            }
 72
 73            public void ReportDiagnostic(Diagnostic diagnostic)
 74            {
 075                _context.ReportDiagnostic(diagnostic);
 076            }
 77
 78            public void AddSource(string hintName, SourceText sourceText)
 79            {
 5280                _context.AddSource(hintName, sourceText);
 5281            }
 82        }
 83    }
 84}

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.BuildTools/src/OperationInvokerGenerator.SourceGenerationSpec.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Collections.Immutable;
 5
 6namespace CoreWCF.BuildTools;
 7
 8public sealed partial class OperationInvokerGenerator
 9{
 10    internal readonly record struct SourceGenerationSpec(in ImmutableArray<OperationContractSpec> OperationContractSpecs
 11    {
 15612        public ImmutableArray<OperationContractSpec> OperationContractSpecs { get; } = OperationContractSpecs;
 13
 14        public static readonly SourceGenerationSpec None = new();
 15    }
 16}

Methods/Properties

.cctor()
.ctor(CoreWCF.BuildTools.OperationInvokerGenerator/OperationInvokerSourceGenerationContext&,CoreWCF.BuildTools.OperationInvokerGenerator/SourceGenerationSpec&)
Emit()
EmitOperationContract(CoreWCF.BuildTools.OperationInvokerGenerator/OperationContractSpec,System.Int32)
GetOperationInvokerTypeName(System.Int32)
EscapeIdentifier(System.String)
FlowsIn(Microsoft.CodeAnalysis.IParameterSymbol)
FlowOut(Microsoft.CodeAnalysis.IParameterSymbol)
GetRefKind(Microsoft.CodeAnalysis.IParameterSymbol)
Method()
.cctor()
.ctor(Microsoft.CodeAnalysis.Compilation,CoreWCF.BuildTools.OperationInvokerGenerator/OperationInvokerSourceGenerationContext&)
GetGenerationSpec(System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.Syntax.InterfaceDeclarationSyntax>)
GetOperationContracts()
EnumerateServiceContracts()
HasOpenGenericContext(Microsoft.CodeAnalysis.IMethodSymbol)
HasOpenGenericContext(Microsoft.CodeAnalysis.INamedTypeSymbol)
IsOpenGenericType(Microsoft.CodeAnalysis.INamedTypeSymbol)
ContainsTypeParameter(Microsoft.CodeAnalysis.ITypeSymbol)
IsSyntaxTargetForGeneration(Microsoft.CodeAnalysis.SyntaxNode)
GetSemanticTargetForGeneration(Microsoft.CodeAnalysis.GeneratorSyntaxContext)
Initialize(Microsoft.CodeAnalysis.GeneratorInitializationContext)
Execute(Microsoft.CodeAnalysis.GeneratorExecutionContext)
InterfaceDeclarationSyntaxList()
OnVisitSyntaxNode(Microsoft.CodeAnalysis.GeneratorSyntaxContext)
.ctor(Microsoft.CodeAnalysis.GeneratorExecutionContext)
ReportDiagnostic(Microsoft.CodeAnalysis.Diagnostic)
AddSource(System.String,Microsoft.CodeAnalysis.Text.SourceText)
OperationContractSpecs()