diff --git a/.csharpierignore b/.csharpierignore
new file mode 100644
index 000000000..d0f9d4c20
--- /dev/null
+++ b/.csharpierignore
@@ -0,0 +1,2 @@
+# Exclude Packages folders (Unity packages and third-party code)
+**/Packages/**
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..7b2b08069
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,24 @@
+name: Run Checks
+on:
+ pull_request:
+ branches:
+ - "**"
+
+jobs:
+ test:
+ runs-on: ubuntu-22.04
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v5
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v5
+ with:
+ dotnet-version: "8.0.x"
+
+ - name: Install CSharpier
+ run: dotnet tool install -g csharpier
+
+ - name: Check formatting
+ run: csharpier check .
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 000000000..6a14f76f5
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,3 @@
+{
+ "recommendations": ["csharpier.csharpier-vscode"]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 000000000..2ac044a84
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,7 @@
+{
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "editor.formatOnSave": true,
+ "[csharp]": {
+ "editor.defaultFormatter": "csharpier.csharpier-vscode"
+ }
+}
diff --git a/OneSignalExample/Assets/App/Editor/iOS/BuildPostProcessor.cs b/OneSignalExample/Assets/App/Editor/iOS/BuildPostProcessor.cs
index fd90164d4..87662db2c 100644
--- a/OneSignalExample/Assets/App/Editor/iOS/BuildPostProcessor.cs
+++ b/OneSignalExample/Assets/App/Editor/iOS/BuildPostProcessor.cs
@@ -35,17 +35,23 @@
using System.IO;
using System.Linq;
-namespace App.Editor.iOS {
+namespace App.Editor.iOS
+{
///
/// Adds the ExampleWidgetExtension to the iOS project frameworks to the iOS project and enables the main target
/// for Live Activities.
///
- public class BuildPostProcessor : IPostprocessBuildWithReport {
-
+ public class BuildPostProcessor : IPostprocessBuildWithReport
+ {
private static readonly string WdigetExtensionTargetRelativePath = "ExampleWidget";
private static readonly string WidgetExtensionTargetName = "ExampleWidgetExtension";
private static readonly string WidgetExtensionPath = Path.Combine("iOS", "ExampleWidget");
- private static readonly string[] WidgetExtensionFiles = new string[] { "Assets.xcassets", "ExampleWidgetBundle.swift", "ExampleWidgetLiveActivity.swift" };
+ private static readonly string[] WidgetExtensionFiles = new string[]
+ {
+ "Assets.xcassets",
+ "ExampleWidgetBundle.swift",
+ "ExampleWidgetLiveActivity.swift",
+ };
///
/// must be between 40 and 50 to ensure that it's not overriden by Podfile generation (40) and that it's
@@ -54,22 +60,32 @@ public class BuildPostProcessor : IPostprocessBuildWithReport {
///
public int callbackOrder => 45;
- public void OnPostprocessBuild(BuildReport report) {
+ public void OnPostprocessBuild(BuildReport report)
+ {
if (report.summary.platform != BuildTarget.iOS)
return;
- Debug.Log("BuildPostProcessor.OnPostprocessBuild for target " + report.summary.platform + " at path " + report.summary.outputPath + " with CWD " + Directory.GetCurrentDirectory());
+ Debug.Log(
+ "BuildPostProcessor.OnPostprocessBuild for target "
+ + report.summary.platform
+ + " at path "
+ + report.summary.outputPath
+ + " with CWD "
+ + Directory.GetCurrentDirectory()
+ );
EnableAppForLiveActivities(report.summary.outputPath);
CreateWidgetExtension(report.summary.outputPath);
-
+
Debug.Log("BuildPostProcessor.OnPostprocessBuild complete");
}
- static void EnableAppForLiveActivities(string outputPath) {
+ static void EnableAppForLiveActivities(string outputPath)
+ {
var plistPath = Path.Combine(outputPath, "Info.plist");
- if (!File.Exists(plistPath)) {
+ if (!File.Exists(plistPath))
+ {
Debug.LogError($"Could not find PList {plistPath}!");
return;
}
@@ -80,12 +96,14 @@ static void EnableAppForLiveActivities(string outputPath) {
mainPlist.WriteToFile(plistPath);
}
- static void CreateWidgetExtension(string outputPath) {
+ static void CreateWidgetExtension(string outputPath)
+ {
AddWidgetExtensionToProject(outputPath);
AddWidgetExtensionToPodFile(outputPath);
}
- static void AddWidgetExtensionToProject(string outputPath) {
+ static void AddWidgetExtensionToProject(string outputPath)
+ {
var project = new PBXProject();
var projectPath = PBXProject.GetPBXProjectPath(outputPath);
project.ReadFromString(File.ReadAllText(projectPath));
@@ -99,9 +117,13 @@ static void AddWidgetExtensionToProject(string outputPath) {
var widgetDestPath = Path.Combine(outputPath, WdigetExtensionTargetRelativePath);
Directory.CreateDirectory(widgetDestPath);
- CopyFileOrDirectory(Path.Combine(WidgetExtensionPath, "Info.plist"), Path.Combine(widgetDestPath, "Info.plist"));
+ CopyFileOrDirectory(
+ Path.Combine(WidgetExtensionPath, "Info.plist"),
+ Path.Combine(widgetDestPath, "Info.plist")
+ );
- extensionGuid = project.AddAppExtension(project.GetUnityMainTargetGuid(),
+ extensionGuid = project.AddAppExtension(
+ project.GetUnityMainTargetGuid(),
WidgetExtensionTargetName,
$"{PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS)}.{WidgetExtensionTargetName}",
$"{WdigetExtensionTargetRelativePath}/Info.plist"
@@ -109,11 +131,15 @@ static void AddWidgetExtensionToProject(string outputPath) {
var buildPhaseID = project.AddSourcesBuildPhase(extensionGuid);
- foreach (var file in WidgetExtensionFiles) {
+ foreach (var file in WidgetExtensionFiles)
+ {
var destPathRelative = Path.Combine(WdigetExtensionTargetRelativePath, file);
var sourceFileGuid = project.AddFile(destPathRelative, destPathRelative);
project.AddFileToBuildSection(extensionGuid, buildPhaseID, sourceFileGuid);
- CopyFileOrDirectory(Path.Combine(WidgetExtensionPath, file), Path.Combine(outputPath, destPathRelative));
+ CopyFileOrDirectory(
+ Path.Combine(WidgetExtensionPath, file),
+ Path.Combine(outputPath, destPathRelative)
+ );
}
project.SetBuildProperty(extensionGuid, "TARGETED_DEVICE_FAMILY", "1,2");
@@ -123,16 +149,19 @@ static void AddWidgetExtensionToProject(string outputPath) {
project.WriteToFile(projectPath);
}
- static void AddWidgetExtensionToPodFile(string outputPath) {
+ static void AddWidgetExtensionToPodFile(string outputPath)
+ {
var podfilePath = Path.Combine(outputPath, "Podfile");
- if (!File.Exists(podfilePath)) {
+ if (!File.Exists(podfilePath))
+ {
Debug.LogError($"Could not find Podfile {podfilePath}!");
return;
}
var podfile = File.ReadAllText(podfilePath);
- podfile += $"target '{WidgetExtensionTargetName}' do\n pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0'\nend\n";
+ podfile +=
+ $"target '{WidgetExtensionTargetName}' do\n pod 'OneSignalXCFramework', '>= 5.0.2', '< 6.0.0'\nend\n";
File.WriteAllText(podfilePath, podfile);
}
@@ -150,20 +179,29 @@ static void CopyFileOrDirectory(string sourcePath, string destinationPath)
{
file.CopyTo(destinationPath, true);
}
- else {
- Directory.CreateDirectory(destinationPath);
+ else
+ {
+ Directory.CreateDirectory(destinationPath);
- foreach (FileInfo childFile in dir.EnumerateFiles().Where(f => !f.Name.EndsWith(".meta")))
+ foreach (
+ FileInfo childFile in dir.EnumerateFiles().Where(f => !f.Name.EndsWith(".meta"))
+ )
{
- CopyFileOrDirectory(childFile.FullName, Path.Combine(destinationPath, childFile.Name));
+ CopyFileOrDirectory(
+ childFile.FullName,
+ Path.Combine(destinationPath, childFile.Name)
+ );
}
foreach (DirectoryInfo subDir in dir.GetDirectories())
{
- CopyFileOrDirectory(subDir.FullName, Path.Combine(destinationPath, subDir.Name));
+ CopyFileOrDirectory(
+ subDir.FullName,
+ Path.Combine(destinationPath, subDir.Name)
+ );
}
}
}
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/OneSignalExample/Assets/OneSignal/Attribution/OneSignalVSAttribution.cs b/OneSignalExample/Assets/OneSignal/Attribution/OneSignalVSAttribution.cs
index 72c6b5c20..b810d2857 100644
--- a/OneSignalExample/Assets/OneSignal/Attribution/OneSignalVSAttribution.cs
+++ b/OneSignalExample/Assets/OneSignal/Attribution/OneSignalVSAttribution.cs
@@ -25,19 +25,23 @@
* THE SOFTWARE.
*/
-using UnityEngine;
using UnityEditor.VSAttribution.OneSignalSDK;
+using UnityEngine;
namespace OneSignalSDK
{
- internal static class AttachToInit {
- #if ONE_SIGNAL_INSTALLED
- [RuntimeInitializeOnLoadMethod] public static void Init() {
- if (string.IsNullOrEmpty(OneSignalPlatform.AppId))
- OneSignalPlatform.OnInitialize += appId => VSAttribution.SendAttributionEvent("Login", "OneSignal", appId);
- else
- VSAttribution.SendAttributionEvent("Login", "OneSignal", OneSignalPlatform.AppId);
- }
- #endif
+ internal static class AttachToInit
+ {
+#if ONE_SIGNAL_INSTALLED
+ [RuntimeInitializeOnLoadMethod]
+ public static void Init()
+ {
+ if (string.IsNullOrEmpty(OneSignalPlatform.AppId))
+ OneSignalPlatform.OnInitialize += appId =>
+ VSAttribution.SendAttributionEvent("Login", "OneSignal", appId);
+ else
+ VSAttribution.SendAttributionEvent("Login", "OneSignal", OneSignalPlatform.AppId);
+ }
+#endif
}
-}
\ No newline at end of file
+}
diff --git a/OneSignalExample/Assets/OneSignal/Attribution/VSAttribution.cs b/OneSignalExample/Assets/OneSignal/Attribution/VSAttribution.cs
index 983db0fc1..190b56ce3 100644
--- a/OneSignalExample/Assets/OneSignal/Attribution/VSAttribution.cs
+++ b/OneSignalExample/Assets/OneSignal/Attribution/VSAttribution.cs
@@ -3,66 +3,75 @@
namespace UnityEditor.VSAttribution.OneSignalSDK
{
- public static class VSAttribution
- {
- const int k_VersionId = 4;
- const int k_MaxEventsPerHour = 10;
- const int k_MaxNumberOfElements = 1000;
+ public static class VSAttribution
+ {
+ const int k_VersionId = 4;
+ const int k_MaxEventsPerHour = 10;
+ const int k_MaxNumberOfElements = 1000;
- const string k_VendorKey = "unity.vsp-attribution";
- const string k_EventName = "vspAttribution";
+ const string k_VendorKey = "unity.vsp-attribution";
+ const string k_EventName = "vspAttribution";
- static bool RegisterEvent()
- {
- AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour,
- k_MaxNumberOfElements, k_VendorKey, k_VersionId);
+ static bool RegisterEvent()
+ {
+ AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(
+ k_EventName,
+ k_MaxEventsPerHour,
+ k_MaxNumberOfElements,
+ k_VendorKey,
+ k_VersionId
+ );
- var isResultOk = result == AnalyticsResult.Ok;
- return isResultOk;
- }
+ var isResultOk = result == AnalyticsResult.Ok;
+ return isResultOk;
+ }
- [Serializable]
- struct VSAttributionData
- {
- public string actionName;
- public string partnerName;
- public string customerUid;
- public string extra;
- }
+ [Serializable]
+ struct VSAttributionData
+ {
+ public string actionName;
+ public string partnerName;
+ public string customerUid;
+ public string extra;
+ }
- ///
- /// Registers and attempts to send a Verified Solutions Attribution event.
- ///
- /// Name of the action, identifying a place this event was called from.
- /// Identifiable Verified Solutions Partner's name.
- /// Unique identifier of the customer using Partner's Verified Solution.
- public static AnalyticsResult SendAttributionEvent(string actionName, string partnerName, string customerUid)
- {
- try
- {
- // Are Editor Analytics enabled ? (Preferences)
- if (!EditorAnalytics.enabled)
- return AnalyticsResult.AnalyticsDisabled;
+ ///
+ /// Registers and attempts to send a Verified Solutions Attribution event.
+ ///
+ /// Name of the action, identifying a place this event was called from.
+ /// Identifiable Verified Solutions Partner's name.
+ /// Unique identifier of the customer using Partner's Verified Solution.
+ public static AnalyticsResult SendAttributionEvent(
+ string actionName,
+ string partnerName,
+ string customerUid
+ )
+ {
+ try
+ {
+ // Are Editor Analytics enabled ? (Preferences)
+ if (!EditorAnalytics.enabled)
+ return AnalyticsResult.AnalyticsDisabled;
- if (!RegisterEvent())
- return AnalyticsResult.InvalidData;
+ if (!RegisterEvent())
+ return AnalyticsResult.InvalidData;
- // Create an expected data object
- var eventData = new VSAttributionData
- {
- actionName = actionName,
- partnerName = partnerName,
- customerUid = customerUid,
- extra = "{}"
- };
+ // Create an expected data object
+ var eventData = new VSAttributionData
+ {
+ actionName = actionName,
+ partnerName = partnerName,
+ customerUid = customerUid,
+ extra = "{}",
+ };
- return EditorAnalytics.SendEventWithLimit(k_EventName, eventData, k_VersionId);
- }
- catch
- {
- // Fail silently
- return AnalyticsResult.AnalyticsDisabled;
- }
- }
- }
-}
\ No newline at end of file
+ return EditorAnalytics.SendEventWithLimit(k_EventName, eventData, k_VersionId);
+ }
+ catch
+ {
+ // Fail silently
+ return AnalyticsResult.AnalyticsDisabled;
+ }
+ }
+ }
+}
diff --git a/OneSignalExample/Assets/OneSignal/Editor/AssemblyInfo.cs b/OneSignalExample/Assets/OneSignal/Editor/AssemblyInfo.cs
index 518b784b8..07e934721 100644
--- a/OneSignalExample/Assets/OneSignal/Editor/AssemblyInfo.cs
+++ b/OneSignalExample/Assets/OneSignal/Editor/AssemblyInfo.cs
@@ -27,4 +27,4 @@
using System.Runtime.CompilerServices;
-[assembly: InternalsVisibleTo("OneSignal.Packager")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("OneSignal.Packager")]
diff --git a/OneSignalExample/Assets/OneSignal/Editor/OneSignalBootstrapper.cs b/OneSignalExample/Assets/OneSignal/Editor/OneSignalBootstrapper.cs
index 60b1063bc..240291528 100644
--- a/OneSignalExample/Assets/OneSignal/Editor/OneSignalBootstrapper.cs
+++ b/OneSignalExample/Assets/OneSignal/Editor/OneSignalBootstrapper.cs
@@ -28,15 +28,19 @@
using System.Linq;
using UnityEditor;
-namespace OneSignalSDK {
+namespace OneSignalSDK
+{
///
/// Handles informing the user on startup/import if the legacy SDK has been detected
///
- public static class OneSignalBootstrapper {
+ public static class OneSignalBootstrapper
+ {
///
/// Asks to open the SDK Setup if legacy files are found or core is missing
///
- [InitializeOnLoadMethod] public static void CheckForLegacy() {
+ [InitializeOnLoadMethod]
+ public static void CheckForLegacy()
+ {
if (SessionState.GetBool(_sessionCheckKey, false))
return;
@@ -45,24 +49,28 @@ [InitializeOnLoadMethod] public static void CheckForLegacy() {
EditorApplication.delayCall += _checkForLegacy;
}
- private static void _checkForLegacy() {
- #if !ONE_SIGNAL_INSTALLED
+ private static void _checkForLegacy()
+ {
+#if !ONE_SIGNAL_INSTALLED
EditorApplication.delayCall += _showOpenSetupDialog;
- #else
- var inventory = AssetDatabase.LoadAssetAtPath(OneSignalFileInventory.AssetPath);
+#else
+ var inventory = AssetDatabase.LoadAssetAtPath(
+ OneSignalFileInventory.AssetPath
+ );
if (inventory == null)
return; // error
var currentPaths = OneSignalFileInventory.GetCurrentPaths();
- var diff = currentPaths.Except(inventory.DistributedPaths);
+ var diff = currentPaths.Except(inventory.DistributedPaths);
if (diff.Any())
EditorApplication.delayCall += _showOpenSetupDialog;
- #endif
+#endif
}
- private static void _showOpenSetupDialog() {
+ private static void _showOpenSetupDialog()
+ {
var dialogResult = EditorUtility.DisplayDialog(
"OneSignal",
"The project contains an outdated or incomplete install of OneSignal SDK! We recommend running the OneSignal SDK Setup.",
@@ -76,4 +84,4 @@ private static void _showOpenSetupDialog() {
private const string _sessionCheckKey = "onesignal.bootstrapper.check";
}
-}
\ No newline at end of file
+}
diff --git a/OneSignalExample/Assets/OneSignal/Editor/OneSignalFileInventory.cs b/OneSignalExample/Assets/OneSignal/Editor/OneSignalFileInventory.cs
index 09c729220..578cf5853 100644
--- a/OneSignalExample/Assets/OneSignal/Editor/OneSignalFileInventory.cs
+++ b/OneSignalExample/Assets/OneSignal/Editor/OneSignalFileInventory.cs
@@ -29,11 +29,13 @@
using System.Linq;
using UnityEngine;
-namespace OneSignalSDK {
+namespace OneSignalSDK
+{
///
/// Inventory distributed with the *.unitypackage in order to determine if there are any legacy files in need of removal
///
- internal sealed class OneSignalFileInventory : ScriptableObject {
+ internal sealed class OneSignalFileInventory : ScriptableObject
+ {
///
/// Array of paths within the OneSignal directory which were determined to be part of the distributed unitypackage
///
@@ -42,8 +44,10 @@ internal sealed class OneSignalFileInventory : ScriptableObject {
///
/// Array of current paths within the OneSignal directory
///
- public static string[] GetCurrentPaths()
- => ConvertPathsToUnix(Directory.GetFiles(PackageAssetsPath, "*", SearchOption.AllDirectories));
+ public static string[] GetCurrentPaths() =>
+ ConvertPathsToUnix(
+ Directory.GetFiles(PackageAssetsPath, "*", SearchOption.AllDirectories)
+ );
///
/// Makes sure are using forward slash to be Unix compatible.
@@ -51,7 +55,8 @@ public static string[] GetCurrentPaths()
///
/// the paths to check and convert
/// paths with / as the directory separator
- public static string[] ConvertPathsToUnix(string[] paths) {
+ public static string[] ConvertPathsToUnix(string[] paths)
+ {
if (Path.DirectorySeparatorChar == Path.AltDirectorySeparatorChar)
return paths;
@@ -64,7 +69,11 @@ public static string[] ConvertPathsToUnix(string[] paths) {
public const string AssetName = "OneSignalFileInventory.asset";
public static readonly string PackageAssetsPath = Path.Combine("Assets", "OneSignal");
- public static readonly string EditorResourcesPath = Path.Combine(PackageAssetsPath, "Editor", "Resources");
+ public static readonly string EditorResourcesPath = Path.Combine(
+ PackageAssetsPath,
+ "Editor",
+ "Resources"
+ );
public static readonly string AssetPath = Path.Combine(EditorResourcesPath, AssetName);
}
-}
\ No newline at end of file
+}
diff --git a/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Dependency.cs b/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Dependency.cs
index 7339fad33..c85b4fb4d 100644
--- a/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Dependency.cs
+++ b/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Dependency.cs
@@ -27,11 +27,13 @@
using System.Collections.Generic;
-namespace OneSignalSDK {
+namespace OneSignalSDK
+{
///
/// Representation of the manifest file "dependency" entry.
///
- public class Dependency {
+ public class Dependency
+ {
///
/// The dependency name.
///
@@ -47,8 +49,9 @@ public class Dependency {
///
/// Dependency name.
/// Dependency version.
- public Dependency(string name, string version) {
- Name = name;
+ public Dependency(string name, string version)
+ {
+ Name = name;
Version = version;
}
@@ -56,7 +59,8 @@ public Dependency(string name, string version) {
/// Sets new dependency version.
///
/// The version to be set for this dependency
- public void SetVersion(string version) {
+ public void SetVersion(string version)
+ {
Version = version;
}
@@ -64,11 +68,12 @@ public void SetVersion(string version) {
/// Creates a dictionary from this object.
///
/// Dependency object representation as Dictionary<string, object>.
- public Dictionary ToDictionary() {
+ public Dictionary ToDictionary()
+ {
Dictionary result = new Dictionary();
result.Add(Name, Version);
return result;
}
}
-}
\ No newline at end of file
+}
diff --git a/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Manifest.cs b/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Manifest.cs
index 14d4d43e6..fcbccbff4 100644
--- a/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Manifest.cs
+++ b/OneSignalExample/Assets/OneSignal/Editor/PackageManagement/Manifest.cs
@@ -29,12 +29,14 @@
using System.IO;
using OneSignalSDK.Installer;
-namespace OneSignalSDK {
+namespace OneSignalSDK
+{
///
/// Representation of Manifest JSON file.
/// Can be used for adding dependencies, scopeRegistries, etc to .json file
///
- public class Manifest {
+ public class Manifest
+ {
const string k_ProjectManifestPath = "Packages/manifest.json";
const string k_DependenciesKey = "dependencies";
const string k_ScopedRegistriesKey = "scopedRegistries";
@@ -53,33 +55,44 @@ public class Manifest {
/// Initializes a new instance of the class.
///
/// Path to manifest file.
- public Manifest(string pathToFile = k_ProjectManifestPath) {
- Path = pathToFile;
+ public Manifest(string pathToFile = k_ProjectManifestPath)
+ {
+ Path = pathToFile;
m_ScopeRegistries = new Dictionary();
- m_Dependencies = new Dictionary();
+ m_Dependencies = new Dictionary();
}
///
/// Read the Manifest file and deserialize its content from JSON.
///
- public void Fetch() {
+ public void Fetch()
+ {
var manifestText = File.ReadAllText(Path);
m_RawContent = (Dictionary)Json.Deserialize(manifestText);
- if (m_RawContent.TryGetValue(k_ScopedRegistriesKey, out var registriesBlob)) {
- if (registriesBlob is List