Skip to content

Commit 4315cad

Browse files
authored
TurboModule spec checking should accept hstring for string arguments (#14322)
* TurboModule spec checking should accept hstring for string arguments * Change files * example
1 parent 9ccccd6 commit 4315cad

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "TurboModule spec checking should accept hstring for string arguments",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative.Cxx/NativeModules.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,26 @@ constexpr bool MatchInputArg<std::string, std::wstring>() noexcept {
411411
return true;
412412
}
413413

414+
template <>
415+
constexpr bool MatchInputArg<std::string, winrt::hstring>() noexcept {
416+
return true;
417+
}
418+
419+
template <>
420+
constexpr bool MatchInputArg<winrt::hstring, std::string>() noexcept {
421+
return true;
422+
}
423+
424+
template <>
425+
constexpr bool MatchInputArg<std::wstring, winrt::hstring>() noexcept {
426+
return true;
427+
}
428+
429+
template <>
430+
constexpr bool MatchInputArg<winrt::hstring, std::wstring>() noexcept {
431+
return true;
432+
}
433+
414434
template <class TResult, class TInputArgs, class TOutputCallbacks, class TOutputPromises>
415435
struct MethodSignature {
416436
using Result = TResult;

vnext/Microsoft.ReactNative/Modules/ClipboardModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void Clipboard::getString(React::ReactPromise<std::string> result) noexcept {
4848
);
4949
}
5050

51-
void Clipboard::setString(std::wstring content) noexcept {
51+
void Clipboard::setString(winrt::hstring content) noexcept {
5252
m_reactContext.UIDispatcher().Post([=] {
5353
DataTransfer::DataPackage data;
5454
data.SetText(content);

vnext/Microsoft.ReactNative/Modules/ClipboardModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Clipboard {
1818
void getString(winrt::Microsoft::ReactNative::ReactPromise<std::string> result) noexcept;
1919

2020
REACT_METHOD(setString)
21-
void setString(std::wstring content) noexcept;
21+
void setString(winrt::hstring content) noexcept;
2222

2323
winrt::Microsoft::ReactNative::ReactContext m_reactContext;
2424
};

0 commit comments

Comments
 (0)