Add @DoNotStrip to exported methods in NativeModule specs

Summary:
NativeModule methods are meant to be called from JavaScript. As such, they may not necessarily have call-sites in Java. This means that they're succeptible to being stripped by proguard.

This diff annotates all exported NativeModule methods with DoNotStrip, so that proguard doesn't strip them. We already do this in the legacy codegen.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25723801

fbshipit-source-id: a7c8701e0a5d03a970f5f19cc6ae6b320a2e99a1
This commit is contained in:
Ramanpreet Nara
2020-12-29 13:04:36 -08:00
committed by Facebook GitHub Bot
parent c776f09e5f
commit 6740b22ab0
3 changed files with 37 additions and 1 deletions
@@ -395,6 +395,7 @@ module.exports = {
'com.facebook.react.bridge.ReactMethod',
'com.facebook.react.bridge.ReactModuleWithSpec',
'com.facebook.react.turbomodule.core.interfaces.TurboModule',
'com.facebook.proguard.annotations.DoNotStrip',
]);
const methods = properties.map(method => {
@@ -443,7 +444,7 @@ module.exports = {
const methodJavaAnnotation = `@ReactMethod${
isSyncMethod ? '(isBlockingSynchronousMethod = true)' : ''
}`;
}\n @DoNotStrip`;
const methodBody = method.optional
? getFalsyReturnStatementFromReturnType(
methodTypeAnnotation.returnTypeAnnotation,