@@ -109,7 +109,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
109
109
context . RegisterConcatenatedSyntaxOutputs ( generateSingleStub . Select ( ( data , ct ) => data . Item1 ) , "LibraryImports.g.cs" ) ;
110
110
}
111
111
112
- private static List < AttributeSyntax > GenerateSyntaxForForwardedAttributes ( AttributeData ? suppressGCTransitionAttribute , AttributeData ? unmanagedCallConvAttribute , AttributeData ? defaultDllImportSearchPathsAttribute )
112
+ private static List < AttributeSyntax > GenerateSyntaxForForwardedAttributes ( AttributeData ? suppressGCTransitionAttribute , AttributeData ? unmanagedCallConvAttribute , AttributeData ? defaultDllImportSearchPathsAttribute , AttributeData ? wasmImportLinkageAttribute )
113
113
{
114
114
const string CallConvsField = "CallConvs" ;
115
115
// Manually rehydrate the forwarded attributes with fully qualified types so we don't have to worry about any using directives.
@@ -153,6 +153,10 @@ private static List<AttributeSyntax> GenerateSyntaxForForwardedAttributes(Attrib
153
153
LiteralExpression ( SyntaxKind . NumericLiteralExpression ,
154
154
Literal ( ( int ) defaultDllImportSearchPathsAttribute . ConstructorArguments [ 0 ] . Value ! ) ) ) ) ) ) ;
155
155
}
156
+ if ( wasmImportLinkageAttribute is not null )
157
+ {
158
+ attributes . Add ( Attribute ( NameSyntaxes . WasmImportLinkageAttribute ) ) ;
159
+ }
156
160
return attributes ;
157
161
}
158
162
@@ -223,12 +227,14 @@ private static IncrementalStubGenerationContext CalculateStubInformation(
223
227
INamedTypeSymbol ? suppressGCTransitionAttrType = environment . SuppressGCTransitionAttrType ;
224
228
INamedTypeSymbol ? unmanagedCallConvAttrType = environment . UnmanagedCallConvAttrType ;
225
229
INamedTypeSymbol ? defaultDllImportSearchPathsAttrType = environment . DefaultDllImportSearchPathsAttrType ;
230
+ INamedTypeSymbol ? wasmImportLinkageAttrType = environment . WasmImportLinkageAttrType ;
226
231
// Get any attributes of interest on the method
227
232
AttributeData ? generatedDllImportAttr = null ;
228
233
AttributeData ? lcidConversionAttr = null ;
229
234
AttributeData ? suppressGCTransitionAttribute = null ;
230
235
AttributeData ? unmanagedCallConvAttribute = null ;
231
236
AttributeData ? defaultDllImportSearchPathsAttribute = null ;
237
+ AttributeData ? wasmImportLinkageAttribute = null ;
232
238
foreach ( AttributeData attr in symbol . GetAttributes ( ) )
233
239
{
234
240
if ( attr . AttributeClass is not null
@@ -252,6 +258,10 @@ private static IncrementalStubGenerationContext CalculateStubInformation(
252
258
{
253
259
defaultDllImportSearchPathsAttribute = attr ;
254
260
}
261
+ else if ( wasmImportLinkageAttrType is not null && SymbolEqualityComparer . Default . Equals ( attr . AttributeClass , wasmImportLinkageAttrType ) )
262
+ {
263
+ wasmImportLinkageAttribute = attr ;
264
+ }
255
265
}
256
266
257
267
Debug . Assert ( generatedDllImportAttr is not null ) ;
@@ -299,7 +309,7 @@ private static IncrementalStubGenerationContext CalculateStubInformation(
299
309
300
310
var methodSyntaxTemplate = new ContainingSyntax ( originalSyntax . Modifiers , SyntaxKind . MethodDeclaration , originalSyntax . Identifier , originalSyntax . TypeParameterList ) ;
301
311
302
- List < AttributeSyntax > additionalAttributes = GenerateSyntaxForForwardedAttributes ( suppressGCTransitionAttribute , unmanagedCallConvAttribute , defaultDllImportSearchPathsAttribute ) ;
312
+ List < AttributeSyntax > additionalAttributes = GenerateSyntaxForForwardedAttributes ( suppressGCTransitionAttribute , unmanagedCallConvAttribute , defaultDllImportSearchPathsAttribute , wasmImportLinkageAttribute ) ;
303
313
return new IncrementalStubGenerationContext (
304
314
signatureContext ,
305
315
containingTypeContext ,
0 commit comments