Skip to content

Commit c5b7a15

Browse files
bemartinmaxgolov
andauthored
Add missing methods and properties to obj-c wrapper with corresponding Xamarin bindings (#750)
* Add Obj-C wrapper to set cache path and add methods returnin a status for Flush and FlushAndTearDown * Update * Another update * Maybe final one * Addressing feedback Co-authored-by: Max Golovanov <[email protected]>
1 parent 238d6da commit c5b7a15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1284
-347
lines changed

build-xamarin.sh

+30-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
if [ "$1" == "help" ] || [ "$1" == "?" ]; then
44
echo
55
echo "build-xamarin.sh usage:"
6-
echo "./build-xamarin.sh [debug|release] [cleanAll|cleanXamarin] [xamarinOnly] [package]"
6+
echo "./build-xamarin.sh [debug|release] [cleanall|cleanxamarin] [xamarinonly|skipios|skipandroid] [package]"
77
echo
88
echo "- debug|release: build configuration to use. Default to release of not specified"
9-
echo "- cleanAll: deletes output and temporary directories for all platforms"
10-
echo "- cleanXamarin: deletes output and temporary directories for the Xamarin solution only"
11-
echo "- xamarinOnly: only builds the Xamarin solution, assuming that iOS and Android SDKs have already been built"
9+
echo "- cleanall: deletes output and temporary directories for all platforms"
10+
echo "- cleanxamarin: deletes output and temporary directories for the Xamarin solution only"
11+
echo "- xamarinonly: only builds the Xamarin solution, assuming that iOS and Android SDKs have already been built"
12+
echo "- skipios: skip building the SDK for iOS, assuming it has already been built"
13+
echo "- skipandroid: skip building the SDK for Android, assuming it has already been built"
1214
echo "- package: packages the Xamarin bindings in a NuGet package"
1315
echo
1416
exit 0
@@ -20,18 +22,26 @@ else
2022
BUILD_CONFIGURATION="release"
2123
fi
2224

23-
if [ "$1" == "cleanXamarin" ] || [ "$2" == "cleanXamarin" ]; then
25+
if [ "$1" == "cleanxamarin" ] || [ "$2" == "cleanxamarin" ]; then
2426
CLEAN_XAMARIN=true
2527
fi
2628

27-
if [ "$1" == "cleanAll" ] || [ "$2" == "cleanAll" ]; then
29+
if [ "$1" == "cleanall" ] || [ "$2" == "cleanall" ]; then
2830
CLEAN_ALL=true
2931
fi
3032

31-
if [ "$1" == "xamarinOnly" ] || [ "$2" == "xamarinOnly" ] || [ "$3" == "xamarinOnly" ] || [ "$4" == "xamarinOnly" ]; then
33+
if [ "$1" == "xamarinonly" ] || [ "$2" == "xamarinonly" ] || [ "$3" == "xamarinonly" ] || [ "$4" == "xamarinonly" ]; then
3234
BUILD_XAMARIN_ONLY=true
3335
fi
3436

37+
if [ "$1" == "skipIos" ] || [ "$2" == "skipios" ] || [ "$3" == "skipios" ] || [ "$4" == "skipios" ]; then
38+
SKIP_IOS_BUILD=true
39+
fi
40+
41+
if [ "$1" == "skipandroid" ] || [ "$2" == "skipandroid" ] || [ "$3" == "skipandroid" ] || [ "$4" == "skipandroid" ]; then
42+
SKIP_ANDROID_BUILD=true
43+
fi
44+
3545
if [ "$1" == "package" ] || [ "$2" == "package" ] || [ "$3" == "package" ] || [ "$4" == "package" ]; then
3646
PACKAGE=true
3747
fi
@@ -70,6 +80,8 @@ set -e
7080

7181
if [ "$BUILD_XAMARIN_ONLY" != true ]; then
7282

83+
if [ "$SKIP_IOS_BUILD" != true ]; then
84+
7385
# Build for iOS
7486
echo "$GREEN ====== Building for iOS $NOCOLOR"
7587
if [ "$CLEAN_ALL" == true ]; then
@@ -90,6 +102,10 @@ if [ "$BUILD_XAMARIN_ONLY" != true ]; then
90102
lipo -create -output libmat.a libmat.arm64.a libmat.arm64e.a libmat.x86_64.a
91103
popd
92104

105+
fi
106+
107+
if [ "$SKIP_ANDROID_BUILD" != true ]; then
108+
93109
# Build for Android
94110
echo "$GREEN ====== Building for Android $NOCOLOR"
95111
pushd ./lib/android_build
@@ -106,6 +122,7 @@ if [ "$BUILD_XAMARIN_ONLY" != true ]; then
106122
popd
107123
popd
108124
fi
125+
fi
109126

110127
echo "$GREEN ====== Copying build artifacts $NOCOLOR"
111128

@@ -128,7 +145,12 @@ msbuild ./Microsoft.Applications.Events.Xamarin.sln /p:Configuration=$BUILD_CONF
128145

129146
if [ "$PACKAGE" == true ]; then
130147
echo "$GREEN ====== Creating NuGet package $NOCOLOR"
131-
nuget pack ./Microsoft.Applications.Events.nuspec
148+
149+
echo "Getting Version number from git Tags"
150+
VERSION=$(git describe --tags --match="v*.*.*" | sed 's/^v\([0-9]*\(\.[0-9]*\)*\).*$/\1/g')
151+
echo "Version: $VERSION"
152+
153+
nuget pack ./Microsoft.Applications.Events.nuspec -Version "$VERSION"
132154
fi
133155

134156
popd

wrappers/obj-c/ODWLogConfiguration.h

+11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@
9898
*/
9999
+(bool)enableSessionReset;
100100

101+
/*!
102+
@brief Sets the cache file path.
103+
@param cacheFilePath A string for the cache path.
104+
*/
105+
+(void)setCacheFilePath:(nonnull NSString *)cacheFilePath;
106+
107+
/*!
108+
@brief Returns the cache file path.
109+
*/
110+
+(nullable NSString *)cacheFilePath;
111+
101112
@end
102113

103114
#include "objc_end.h"

wrappers/obj-c/ODWLogConfiguration.mm

+18
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,22 @@ +(bool)enableSessionReset
113113
return _enableSessionReset;
114114
}
115115

116+
+(void)setCacheFilePath:(nonnull NSString *)cacheFilePath
117+
{
118+
std::string strCacheFilePath = std::string([cacheFilePath UTF8String]);
119+
auto& config = LogManager::GetLogConfiguration();
120+
config[CFG_STR_CACHE_FILE_PATH] = strCacheFilePath;
121+
}
122+
123+
+(nullable NSString *)cacheFilePath
124+
{
125+
auto& config = LogManager::GetLogConfiguration();
126+
std::string strCacheFilePath = config[CFG_STR_CACHE_FILE_PATH];
127+
if (strCacheFilePath.empty())
128+
{
129+
return nil;
130+
}
131+
return [NSString stringWithCString:strCacheFilePath.c_str() encoding:NSUTF8StringEncoding];
132+
}
133+
116134
@end

wrappers/obj-c/ODWLogManager.h

+24-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ NS_ASSUME_NONNULL_BEGIN
2222
ODWBestEffort = 2
2323
};
2424

25+
/*!
26+
@enum ODWStatus
27+
@brief The <b>ODWStatus</b> enumeration contains the status values returned by the Flush and FlushAndTearDown functions
28+
*/
29+
typedef NS_ENUM(NSInteger, ODWStatus)
30+
{
31+
// General failure
32+
ODWEfail = -1,
33+
// Success
34+
ODWSuccess = 0,
35+
// Permission denied
36+
ODWEperm = 1,
37+
// Already done / already in progress
38+
ODWEalready = 2,
39+
// Not implemented or no-op
40+
ODWEnosys = 3,
41+
// Not supported
42+
ODWEnotsup = 4,
43+
};
44+
2545
/*!
2646
@brief Initializes the telemetry logging system with the default cofiguration, using the specified tenant token.
2747
@param tenantToken A string that contains the tenant token.
@@ -66,9 +86,9 @@ NS_ASSUME_NONNULL_BEGIN
6686
+(void)uploadNow;
6787

6888
/*!
69-
@brief Flushes pending telemetry events from memory to disk (to reduce possible data loss).
89+
@brief Flushes pending telemetry events from memory to disk (to reduce possible data loss) and returns the flush operation's status
7090
*/
71-
+(void)flush;
91+
+(ODWStatus)flush;
7292

7393
/*!
7494
@brief Sets the transmit profile for event transmission.
@@ -90,9 +110,9 @@ NS_ASSUME_NONNULL_BEGIN
90110
+(void)resumeTransmission;
91111

92112
/*!
93-
@brief Flushes pending telemetry events from memory to disk, and tears-down the telemetry logging system.
113+
@brief Flushes pending telemetry events from memory to disk, tears-down the telemetry logging system, and returns the flush operation's status
94114
*/
95-
+(void)flushAndTeardown;
115+
+(ODWStatus)flushAndTeardown;
96116

97117
/*!
98118
@brief Resets the transmit profiles to contain only default profiles.

wrappers/obj-c/ODWLogManager.mm

+26-9
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,36 @@ +(void)uploadNow
174174
});
175175
}
176176

177-
+(void)flush
177+
+(ODWStatus)flush
178178
{
179-
PerformActionWithCppExceptionsCatch(^(void) {
180-
LogManager::Flush();
181-
});
179+
try
180+
{
181+
return ((ODWStatus)LogManager::Flush());
182+
}
183+
catch (const std::exception &e)
184+
{
185+
if ([ODWLogConfiguration surfaceCppExceptions])
186+
{
187+
[ODWLogger raiseException: e.what()];
188+
}
189+
[ODWLogger traceException: e.what()];
190+
}
182191
}
183192

184-
+(void)flushAndTeardown
193+
+(ODWStatus)flushAndTeardown
185194
{
186-
PerformActionWithCppExceptionsCatch(^(void) {
187-
LogManager::FlushAndTeardown();
188-
_initialized = false;
189-
});
195+
try
196+
{
197+
ODWStatus status = ((ODWStatus)LogManager::FlushAndTeardown());
198+
}
199+
catch (const std::exception &e)
200+
{
201+
if ([ODWLogConfiguration surfaceCppExceptions])
202+
{
203+
[ODWLogger raiseException: e.what()];
204+
}
205+
[ODWLogger traceException: e.what()];
206+
}
190207
}
191208

192209
+(void)setTransmissionProfile:(ODWTransmissionProfile)profile

wrappers/xamarin/Microsoft.Applications.Events.Xamarin.sln

+36-18
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneDsCppSdk.Android.Binding
1212
EndProject
1313
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneDsCppSdk.iOS.Bindings", "sdk\OneDsCppSdk.iOS.Bindings\OneDsCppSdk.iOS.Bindings.csproj", "{5D41E55E-A4CE-41A6-8C11-AA8047B42779}"
1414
EndProject
15-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneDsCppSdk.Standard", "sdk\OneDsCppSdk.Standard\OneDsCppSdk.Standard.csproj", "{94F7DED5-D868-4189-90F6-12C432C4E233}"
16-
EndProject
1715
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B22167C8-231D-435E-A84D-FA809209E9AF}"
1816
EndProject
1917
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneDsCppSdk.Android.Bindings.Tests", "tests\OneDsCppSdk.Android.Bindings.Tests\OneDsCppSdk.Android.Bindings.Tests.csproj", "{8F95A793-3FCE-429C-A41F-F3DA50695616}"
@@ -26,14 +24,30 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assemblies", "Assemblies",
2624
EndProject
2725
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Android", "Android", "{4184563D-6E23-4B9D-9740-E69CE94C1704}"
2826
ProjectSection(SolutionItems) = preProject
29-
sdk\OneDsCppSdk.Android.Bindings\bin\Release\Microsoft.Applications.Events.dll = sdk\OneDsCppSdk.Android.Bindings\bin\Release\Microsoft.Applications.Events.dll
27+
tests\Assemblies\Debug\Android\Microsoft.Applications.Events.dll = tests\Assemblies\Debug\Android\Microsoft.Applications.Events.dll
3028
EndProjectSection
3129
EndProject
3230
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iOS", "iOS", "{C6FCF35F-91C3-40C3-B6C4-DC38C2CD3388}"
3331
ProjectSection(SolutionItems) = preProject
34-
sdk\OneDsCppSdk.iOS.Bindings\bin\Release\Microsoft.Applications.Events.dll = sdk\OneDsCppSdk.iOS.Bindings\bin\Release\Microsoft.Applications.Events.dll
32+
tests\Assemblies\Debug\iOS\Microsoft.Applications.Events.dll = tests\Assemblies\Debug\iOS\Microsoft.Applications.Events.dll
33+
EndProjectSection
34+
EndProject
35+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{A4CE9531-42A9-4BF1-AF70-3EDEAFCBEC2C}"
36+
EndProject
37+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Release", "Release", "{BE8095C6-0920-4A01-A11F-9C36E521C7D6}"
38+
EndProject
39+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Android", "Android", "{03747500-0962-48F5-B147-18883A315B37}"
40+
ProjectSection(SolutionItems) = preProject
41+
tests\Assemblies\Release\Android\Microsoft.Applications.Events.dll = tests\Assemblies\Release\Android\Microsoft.Applications.Events.dll
3542
EndProjectSection
3643
EndProject
44+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iOS", "iOS", "{39DB02EA-D396-4658-B7CB-021E44129B1D}"
45+
ProjectSection(SolutionItems) = preProject
46+
tests\Assemblies\Release\iOS\Microsoft.Applications.Events.dll = tests\Assemblies\Release\iOS\Microsoft.Applications.Events.dll
47+
EndProjectSection
48+
EndProject
49+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OneDsCppSdk.NetStandard", "sdk\OneDsCppSdk.NetStandard\OneDsCppSdk.NetStandard.csproj", "{E36262E1-C401-4D08-9D4E-0C844114A348}"
50+
EndProject
3751
Global
3852
GlobalSection(SharedMSBuildProjectFiles) = preSolution
3953
tests\OneDsCppSdk.Bindings.Tests.Shared\OneDsCppSdk.Bindings.Tests.Shared.projitems*{1b31f588-729c-4e3a-b2fd-1b32876b9e17}*SharedItemsImports = 4
@@ -69,18 +83,6 @@ Global
6983
{5D41E55E-A4CE-41A6-8C11-AA8047B42779}.Release|iPhone.Build.0 = Release|Any CPU
7084
{5D41E55E-A4CE-41A6-8C11-AA8047B42779}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
7185
{5D41E55E-A4CE-41A6-8C11-AA8047B42779}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
72-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Debug|Any CPU.Build.0 = Debug|Any CPU
74-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Debug|iPhone.ActiveCfg = Debug|Any CPU
75-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Debug|iPhone.Build.0 = Debug|Any CPU
76-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
77-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
78-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Release|Any CPU.ActiveCfg = Release|Any CPU
79-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Release|Any CPU.Build.0 = Release|Any CPU
80-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Release|iPhone.ActiveCfg = Release|Any CPU
81-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Release|iPhone.Build.0 = Release|Any CPU
82-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
83-
{94F7DED5-D868-4189-90F6-12C432C4E233}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
8486
{8F95A793-3FCE-429C-A41F-F3DA50695616}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8587
{8F95A793-3FCE-429C-A41F-F3DA50695616}.Debug|Any CPU.Build.0 = Debug|Any CPU
8688
{8F95A793-3FCE-429C-A41F-F3DA50695616}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
@@ -100,6 +102,18 @@ Global
100102
{1B31F588-729C-4E3A-B2FD-1B32876B9E17}.Release|iPhone.Build.0 = Release|iPhone
101103
{1B31F588-729C-4E3A-B2FD-1B32876B9E17}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
102104
{1B31F588-729C-4E3A-B2FD-1B32876B9E17}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
105+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
106+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Debug|Any CPU.Build.0 = Debug|Any CPU
107+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Debug|iPhone.ActiveCfg = Debug|Any CPU
108+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Debug|iPhone.Build.0 = Debug|Any CPU
109+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
110+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
111+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Release|Any CPU.ActiveCfg = Release|Any CPU
112+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Release|Any CPU.Build.0 = Release|Any CPU
113+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Release|iPhone.ActiveCfg = Release|Any CPU
114+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Release|iPhone.Build.0 = Release|Any CPU
115+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
116+
{E36262E1-C401-4D08-9D4E-0C844114A348}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
103117
EndGlobalSection
104118
GlobalSection(SolutionProperties) = preSolution
105119
HideSolutionNode = FALSE
@@ -109,8 +123,12 @@ Global
109123
{1B31F588-729C-4E3A-B2FD-1B32876B9E17} = {B22167C8-231D-435E-A84D-FA809209E9AF}
110124
{399FBCE4-FCAB-4EC4-B805-449D87DFD4FC} = {B22167C8-231D-435E-A84D-FA809209E9AF}
111125
{73153873-885A-4BE6-8EEB-931202B27039} = {B22167C8-231D-435E-A84D-FA809209E9AF}
112-
{4184563D-6E23-4B9D-9740-E69CE94C1704} = {73153873-885A-4BE6-8EEB-931202B27039}
113-
{C6FCF35F-91C3-40C3-B6C4-DC38C2CD3388} = {73153873-885A-4BE6-8EEB-931202B27039}
126+
{4184563D-6E23-4B9D-9740-E69CE94C1704} = {A4CE9531-42A9-4BF1-AF70-3EDEAFCBEC2C}
127+
{C6FCF35F-91C3-40C3-B6C4-DC38C2CD3388} = {A4CE9531-42A9-4BF1-AF70-3EDEAFCBEC2C}
128+
{A4CE9531-42A9-4BF1-AF70-3EDEAFCBEC2C} = {73153873-885A-4BE6-8EEB-931202B27039}
129+
{BE8095C6-0920-4A01-A11F-9C36E521C7D6} = {73153873-885A-4BE6-8EEB-931202B27039}
130+
{03747500-0962-48F5-B147-18883A315B37} = {BE8095C6-0920-4A01-A11F-9C36E521C7D6}
131+
{39DB02EA-D396-4658-B7CB-021E44129B1D} = {BE8095C6-0920-4A01-A11F-9C36E521C7D6}
114132
EndGlobalSection
115133
GlobalSection(ExtensibilityGlobals) = postSolution
116134
SolutionGuid = {B6D12F53-17B2-416D-8BB0-D771D5F77B10}

wrappers/xamarin/Microsoft.Applications.Events.nuspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>Microsoft.Applications.Events.Xamarin</id>
5-
<version>3.4.276.4</version>
5+
<version>0.0.0.0</version>
66
<authors>Microsoft - One Observability</authors>
77
<description>1DS C++ SDK Xamarin Bindings</description>
88
<requireLicenseAcceptance>false</requireLicenseAcceptance>
@@ -28,8 +28,8 @@
2828
<file src="sdk/OneDsCppSdk.iOS.Bindings/bin/Release/Microsoft.Applications.Events.pdb" target="lib/Xamarin.iOS10/Microsoft.Applications.Events.pdb" />
2929

3030
<!-- netstandard2.0 -->
31-
<file src="sdk/OneDsCppSdk.Standard/bin/Release/netstandard2.0/Microsoft.Applications.Events.dll" target="lib/netstandard2.0/Microsoft.Applications.Events.dll" />
32-
<file src="sdk/OneDsCppSdk.Standard/bin/Release/netstandard2.0/Microsoft.Applications.Events.pdb" target="lib/netstandard2.0/Microsoft.Applications.Events.pdb" />
31+
<file src="sdk/OneDsCppSdk.NetStandard/bin/Release/netstandard2.0/Microsoft.Applications.Events.dll" target="lib/netstandard2.0/Microsoft.Applications.Events.dll" />
32+
<file src="sdk/OneDsCppSdk.NetStandard/bin/Release/netstandard2.0/Microsoft.Applications.Events.pdb" target="lib/netstandard2.0/Microsoft.Applications.Events.pdb" />
3333

3434
</files>
3535
</package>

0 commit comments

Comments
 (0)