Skip to content

Commit

Permalink
Create skeleton for the ComInterfaceGenerator (dotnet#80887)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeff Handley <[email protected]>
  • Loading branch information
jkoritzinsky and jeffhandley authored Feb 15, 2023
1 parent 1c4cc74 commit 0717eda
Show file tree
Hide file tree
Showing 20 changed files with 672 additions and 42 deletions.
9 changes: 9 additions & 0 deletions docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ The diagnostic id values reserved for .NET Libraries analyzer warnings are `SYSL
| __`SYSLIB1088`__ | _`SYSLIB1070`-`SYSLIB1089` reserved for System.Runtime.InteropServices.JavaScript.JSImportGenerator._ |
| __`SYSLIB1089`__ | _`SYSLIB1070`-`SYSLIB1089` reserved for System.Runtime.InteropServices.JavaScript.JSImportGenerator._ |
| __`SYSLIB1090`__ | Invalid 'GeneratedComInterfaceAttribute' usage |
| __`SYSLIB1091`__ | Method is declared in different partial declaration than the 'GeneratedComInterface' attribute. |
| __`SYSLIB1092`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1093`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1094`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1095`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1096`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1097`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1098`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |
| __`SYSLIB1099`__ | _`SYSLIB1092`-`SYSLIB1099` reserved for Microsoft.Interop.ComInteropGenerator._ |


### Diagnostic Suppressions (`SYSLIBSUPPRESS****`)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Ids
public const string InvalidLibraryImportAttributeUsage = Prefix + "1050";
public const string TypeNotSupported = Prefix + "1051";
public const string ConfigurationNotSupported = Prefix + "1052";
public const string MethodNotDeclaredInAttributedInterface = Prefix + "1091";
}

private const string Category = "ComInterfaceGenerator";
Expand Down Expand Up @@ -154,6 +155,16 @@ public class Ids
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ConfigurationNotSupportedDescription)));

public static readonly DiagnosticDescriptor MethodNotDeclaredInAttributedInterface =
new DiagnosticDescriptor(
Ids.MethodNotDeclaredInAttributedInterface,
GetResourceString(nameof(SR.MethodNotDeclaredInAttributedInterfaceTitle)),
GetResourceString(nameof(SR.MethodNotDeclaredInAttributedInterfaceMessage)),
Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.MethodNotDeclaredInAttributedInterfaceDescription)));


private readonly List<Diagnostic> _diagnostics = new List<Diagnostic>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;

namespace Microsoft.Interop
{
internal sealed record IncrementalMethodStubGenerationContext(
SignatureContext SignatureContext,
ContainingSyntaxContext ContainingSyntaxContext,
ContainingSyntax StubMethodSyntaxTemplate,
MethodSignatureDiagnosticLocations DiagnosticLocation,
SequenceEqualImmutableArray<FunctionPointerUnmanagedCallingConventionSyntax> CallingConvention,
VirtualMethodIndexData VtableIndexData,
MarshallingInfo ExceptionMarshallingInfo,
MarshallingGeneratorFactoryKey<(TargetFramework TargetFramework, Version TargetFrameworkVersion)> ManagedToUnmanagedGeneratorFactory,
MarshallingGeneratorFactoryKey<(TargetFramework TargetFramework, Version TargetFrameworkVersion)> UnmanagedToManagedGeneratorFactory,
ManagedTypeInfo TypeKeyOwner,
SequenceEqualImmutableArray<Diagnostic> Diagnostics);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;

namespace Microsoft.Interop
{
internal static class IncrementalValuesProviderExtensions
{
public static IncrementalValuesProvider<(T Left, U Right)> Zip<T, U>(this IncrementalValuesProvider<T> left, IncrementalValuesProvider<U> right)
{
return left
.Collect()
.Combine(right.Collect())
.SelectMany((data, ct) =>
{
if (data.Left.Length != data.Right.Length)
{
throw new InvalidOperationException("The two value providers must provide the same number of values.");
}
ImmutableArray<(T, U)>.Builder builder = ImmutableArray.CreateBuilder<(T, U)>(data.Left.Length);
for (int i = 0; i < data.Left.Length; i++)
{
builder.Add((data.Left[i], data.Right[i]));
}
return builder.MoveToImmutable();
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,13 @@
<data name="InterfaceTypeNotSupportedMessage" xml:space="preserve">
<value>Using 'GeneratedComInterfaceAttribute' and 'InterfaceTypeAttribute' is not supported with 'ComInterfaceType' value '{0}'.</value>
</data>
<data name="MethodNotDeclaredInAttributedInterfaceDescription" xml:space="preserve">
<value>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</value>
</data>
<data name="MethodNotDeclaredInAttributedInterfaceMessage" xml:space="preserve">
<value>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</value>
</data>
<data name="MethodNotDeclaredInAttributedInterfaceTitle" xml:space="preserve">
<value>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">Neplatné použití VirtualMethodIndexAttribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">U typů, které nejsou podporovány zdrojem generovanými voláními P/Invoke, bude výsledné volání P/Invoke záviset na podkladovém modulu runtime, aby určený typ zařadil.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">Ungültige Verwendung von „VirtualMethodIndexAttribute“</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">Bei Typen, die von dquellgenerierten P/Invokes nicht unterstützt werden, basiert der resultierende P/Invoke auf der zugrunde liegenden Laufzeit, um den angegebenen Typ zu marshallen.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">Uso de ”VirtualMethodIndexAttribute” no válido</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">Para los tipos que no son compatibles con P/Invokes de un generador de código fuente, el P/Invoke resultante se basará en el entorno de ejecución subyacente para serializar las referencias del tipo especificado.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">Utilisation de « VirtualMethodIndexAttribute » non valide</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">Pour les types qui ne sont pas pris en charge par les P/Invok générés par la source, le P/Invoke résultant se base sur le runtime sous-jacent pour marshaler le type spécifié.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">Utilizzo di 'VirtualMethodIndexAttribute' non valido</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">Per i tipi non supportati da P/Invoke generati dall'origine, il P/Invoke risultante si baserà sul runtime sottostante per effettuare il marshalling del tipo specificato.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">'VirtualMethodIndexAttribute' の使用法が無効です</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">ソース生成済みの P/Invoke でサポートされていない型である場合、生成された P/Invoke は、基礎となるなるランタイムに依存して、指定された型をマーシャリングします。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<target state="translated">잘못된 'VirtualMethodIndexAttribute' 사용</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceDescription">
<source>All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</source>
<target state="new">All methods must be declared in the same partial definition of a 'GeneratedComInterface'-attributed interface type to ensure reliable calculation for virtual method table offsets.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceMessage">
<source>The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</source>
<target state="new">The method '{0}' is declared on a different partial definition of the interface '{1}' than the definition that has the 'GeneratedComInterface' attribute</target>
<note />
</trans-unit>
<trans-unit id="MethodNotDeclaredInAttributedInterfaceTitle">
<source>Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</source>
<target state="new">Method is declared in different partial declaration than the 'GeneratedComInterface' attribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedDescription">
<source>For types that are not supported by source-generated P/Invokes, the resulting P/Invoke will rely on the underlying runtime to marshal the specified type.</source>
<target state="translated">소스 생성 P/Invoke에서 지원하지 않는 형식의 경우 결과 P/Invoke는 기본 런타임에 의존하여 지정된 형식을 마샬링합니다.</target>
Expand Down
Loading

0 comments on commit 0717eda

Please sign in to comment.