@@ -245,19 +245,40 @@ private static NamespaceDeclarationSyntax GenerateRegSource(
245245 // will always evaluate to false at runtime, but the linker can't see through at
246246 // build time. It seems there's no attribute to block trimming of a method?
247247 MemberDeclarationSyntax initializerMethod = MethodDeclaration ( PredefinedType ( Token ( SyntaxKind . VoidKeyword ) ) , Identifier ( selfInitName ) )
248- . WithAttributeLists ( List ( new [ ] {
249- AttributeList ( SingletonSeparatedList ( Attribute ( IdentifierName ( Constants . ModuleInitializerAttributeGlobal ) ) ) ) ,
250- } ) )
248+ . WithAttributeLists (
249+ SingletonList < AttributeListSyntax > (
250+ AttributeList (
251+ SeparatedList < AttributeSyntax > (
252+ new SyntaxNodeOrToken [ ] {
253+ Attribute (
254+ IdentifierName ( Constants . ModuleInitializerAttributeGlobal ) ) ,
255+ Token ( SyntaxKind . CommaToken ) ,
256+ Attribute (
257+ IdentifierName ( Constants . DynamicDependencyAttributeGlobal ) )
258+ . WithArgumentList (
259+ AttributeArgumentList (
260+ SeparatedList < AttributeArgumentSyntax > (
261+ new SyntaxNodeOrToken [ ] {
262+ AttributeArgument (
263+ BinaryExpression (
264+ SyntaxKind . BitwiseOrExpression ,
265+ MemberAccessExpression (
266+ SyntaxKind . SimpleMemberAccessExpression ,
267+ IdentifierName ( Constants . DynamicallyAccessedMemberTypesGlobal ) ,
268+ IdentifierName ( "PublicMethods" ) ) ,
269+ MemberAccessExpression (
270+ SyntaxKind . SimpleMemberAccessExpression ,
271+ IdentifierName ( Constants . DynamicallyAccessedMemberTypesGlobal ) ,
272+ IdentifierName ( "NonPublicMethods" ) ) ) ) ,
273+ Token ( SyntaxKind . CommaToken ) ,
274+ AttributeArgument (
275+ TypeOfExpression (
276+ IdentifierName ( initializerClass ) ) ) } ) ) ) } ) ) ) )
251277 . WithModifiers ( TokenList ( new [ ] {
252278 Token ( SyntaxKind . StaticKeyword ) ,
253279 Token ( SyntaxKind . InternalKeyword )
254280 } ) )
255- . WithBody ( Block (
256- IfStatement ( BinaryExpression ( SyntaxKind . EqualsExpression ,
257- IdentifierName ( "System.Runtime.InteropServices.JavaScript.JSHost.GlobalThis" ) ,
258- LiteralExpression ( SyntaxKind . NullLiteralExpression ) ) ,
259- Block ( SingletonList < StatementSyntax > (
260- ExpressionStatement ( InvocationExpression ( IdentifierName ( initializerName ) ) ) ) ) ) ) ) ;
281+ . WithBody ( Block ( ) ) ;
261282
262283 var ns = NamespaceDeclaration ( IdentifierName ( generatedNamespace ) )
263284 . WithMembers (
0 commit comments