Expose setOsVersion/setOsBuild on Obj-C ODWSemanticContext (resolves #1093)#1482
Expose setOsVersion/setOsBuild on Obj-C ODWSemanticContext (resolves #1093)#1482bmehta001 wants to merge 1 commit into
Conversation
The Obj-C/iOS wrapper exposed app/user/device context setters but no way to override the OS version, so iOS clients could not set DeviceInfo.OsVersion (Common Schema `ext.os.ver`) themselves -- the gap reported in microsoft#1093. The C++ core already provides ISemanticContext::SetOsVersion/SetOsBuild; this wires them through the wrapper. - ODWSemanticContext.h/.mm: add setOsVersion: and setOsBuild:, forwarding to the wrapped ISemanticContext (mirrors the existing setDeviceId pattern). - ODWSemanticContextTests.mm: add testSetOsVersion and testSetOsBuild, with the test mock capturing SetOsVersion/SetOsBuild. Note: per the microsoft#1093 discussion, in the CS3 schema `ext.os.ver` is populated from the OS build (COMMONFIELDS_OS_BUILD), so both setters are exposed. Resolves microsoft#1093. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Validation status for this change: iOS/macOS CI compiled the Obj-C wrapper successfully. The macOS/iOS C++ core API compile-checked locally (WSL, g++ -std=c++11): a mock The forwarding mirrors the existing
|
There was a problem hiding this comment.
Pull request overview
This PR exposes setOsVersion: and setOsBuild: on the Obj-C ODWSemanticContext wrapper so Obj-C/iOS clients can override OS version/build semantic context values that the C++ core already supports, addressing the API gap described in #1093.
Changes:
- Add Obj-C wrapper methods
setOsVersion:/setOsBuild:that forward toISemanticContext::SetOsVersion/SetOsBuild. - Add Obj-C unit tests covering the new setters and extend the test mock to capture the values.
- Update Obj-C header documentation for the new APIs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| wrappers/obj-c/ODWSemanticContext.mm | Adds forwarding implementations for setOsVersion: and setOsBuild:. |
| wrappers/obj-c/ODWSemanticContext.h | Adds public Obj-C API declarations and documentation for the new setters. |
| tests/unittests/obj-c/ODWSemanticContextTests.mm | Adds unit tests and mock capture fields for OS version/build setters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| std::string strOsVersion = std::string([osVersion UTF8String]); | ||
| _wrappedSemanticContext->SetOsVersion(strOsVersion); |
| std::string strOsBuild = std::string([osBuild UTF8String]); | ||
| _wrappedSemanticContext->SetOsBuild(strOsBuild); |
| @brief Set the operating system version context information of telemetry event. | ||
| @details Overrides the OS version that the SDK populates automatically (Common Schema field `ext.os.ver`). | ||
| @param osVersion A string that contains the operating system version. | ||
| */ | ||
| -(void) setOsVersion:(nonnull NSString*)osVersion; |
What
Expose
setOsVersion:andsetOsBuild:on the Obj-C wrapper'sODWSemanticContext, so iOS/Obj-C clients can override the OS version (DeviceInfo.OsVersion/ Common Schemaext.os.ver) the SDK populates automatically.Why
Per #1093, a client needed to set
DeviceInfo.OsVersionfrom app code on iOS. The C++ core already providesISemanticContext::SetOsVersion()/SetOsBuild()(ISemanticContext.hppviaDECLARE_COMMONFIELD), but the Obj-C wrapper exposed only app/user/device-id/experiment setters — no OS-version setter — so there was no way to do this from the Obj-C API. (As noted in the issue thread, in the CS3 schemaext.os.veris populated from the OS build (COMMONFIELDS_OS_BUILD), so both setters are exposed.)Changes
wrappers/obj-c/ODWSemanticContext.h/.mm— addsetOsVersion:andsetOsBuild:, each converting theNSStringtostd::stringand forwarding to the wrappedISemanticContext(SetOsVersion/SetOsBuild). Mirrors the existingsetDeviceId:pattern.tests/unittests/obj-c/ODWSemanticContextTests.mm— addtestSetOsVersionandtestSetOsBuild; the existingTestSemanticContextmock now capturesSetOsVersion/SetOsBuild.Usage
Validation
SetOsVersion/SetOsBuildare non-purevirtual void Set...(const std::string&)generated byDECLARE_COMMONFIELD(CommonFields.h), so the wrapper calls and the test-mockoverrides match the core signatures. The Obj-C wrapper builds and the XCTest run on the macOS/iOS CI — this change couldn't be compiled locally (no Obj-C toolchain on the dev box), so it relies on CI for the build/test confirmation.Resolves #1093.