Skip to content

Commit 52e8c97

Browse files
Merge pull request #436 from OneSignal/feature/cleanup
Clean Up
2 parents 0f063a1 + f18db20 commit 52e8c97

File tree

70 files changed

+2691
-2893
lines changed

Some content is hidden

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

70 files changed

+2691
-2893
lines changed
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1-
using System.Runtime.CompilerServices;
1+
/*
2+
* Modified MIT License
3+
*
4+
* Copyright 2022 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
using System.Runtime.CompilerServices;
229

330
[assembly: InternalsVisibleTo("OneSignal.Packager")]
Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,79 @@
1-
using System.Linq;
1+
/*
2+
* Modified MIT License
3+
*
4+
* Copyright 2022 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
using System.Linq;
229
using UnityEditor;
330

4-
/// <summary>
5-
/// Handles informing the user on startup/import if the legacy SDK has been detected
6-
/// </summary>
7-
public static class OneSignalBootstrapper
8-
{
31+
namespace OneSignalSDK {
932
/// <summary>
10-
/// Asks to open the SDK Setup if legacy files are found or core is missing
33+
/// Handles informing the user on startup/import if the legacy SDK has been detected
1134
/// </summary>
12-
[InitializeOnLoadMethod]
13-
public static void CheckForLegacy()
14-
{
15-
if (SessionState.GetBool(_sessionCheckKey, false))
16-
return;
17-
18-
SessionState.SetBool(_sessionCheckKey, true);
19-
20-
EditorApplication.delayCall += _checkForLegacy;
21-
}
35+
public static class OneSignalBootstrapper {
36+
/// <summary>
37+
/// Asks to open the SDK Setup if legacy files are found or core is missing
38+
/// </summary>
39+
[InitializeOnLoadMethod] public static void CheckForLegacy() {
40+
if (SessionState.GetBool(_sessionCheckKey, false))
41+
return;
2242

23-
private static void _checkForLegacy()
24-
{
25-
#if !ONE_SIGNAL_INSTALLED
26-
EditorApplication.delayCall += _showOpenSetupDialog;
27-
#else
28-
var inventory = AssetDatabase.LoadAssetAtPath<OneSignalFileInventory>(OneSignalFileInventory.AssetPath);
43+
SessionState.SetBool(_sessionCheckKey, true);
2944

30-
if (inventory == null)
31-
return; // error
32-
33-
var currentPaths = OneSignalFileInventory.GetCurrentPaths();
34-
var diff = currentPaths.Except(inventory.DistributedPaths);
45+
EditorApplication.delayCall += _checkForLegacy;
46+
}
3547

36-
if (diff.Any())
48+
private static void _checkForLegacy() {
49+
#if !ONE_SIGNAL_INSTALLED
3750
EditorApplication.delayCall += _showOpenSetupDialog;
38-
#endif
39-
}
51+
#else
52+
var inventory = AssetDatabase.LoadAssetAtPath<OneSignalFileInventory>(OneSignalFileInventory.AssetPath);
4053

41-
private static void _showOpenSetupDialog()
42-
{
43-
var dialogResult = EditorUtility.DisplayDialog(
44-
"OneSignal",
45-
"The project contains an outdated version of OneSignal SDK! We recommend running the OneSignal SDK Setup.",
46-
"Open SDK Setup",
47-
"Cancel"
48-
);
49-
50-
if (dialogResult)
51-
OneSignalSetupWindow.ShowWindow();
52-
}
54+
if (inventory == null)
55+
return; // error
56+
57+
var currentPaths = OneSignalFileInventory.GetCurrentPaths();
58+
var diff = currentPaths.Except(inventory.DistributedPaths);
5359

54-
private const string _sessionCheckKey = "onesignal.bootstrapper.check";
60+
if (diff.Any())
61+
EditorApplication.delayCall += _showOpenSetupDialog;
62+
#endif
63+
}
64+
65+
private static void _showOpenSetupDialog() {
66+
var dialogResult = EditorUtility.DisplayDialog(
67+
"OneSignal",
68+
"The project contains an outdated version of OneSignal SDK! We recommend running the OneSignal SDK Setup.",
69+
"Open SDK Setup",
70+
"Cancel"
71+
);
72+
73+
if (dialogResult)
74+
OneSignalSetupWindow.ShowWindow();
75+
}
76+
77+
private const string _sessionCheckKey = "onesignal.bootstrapper.check";
78+
}
5579
}
Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,70 @@
1+
/*
2+
* Modified MIT License
3+
*
4+
* Copyright 2022 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
128
using System.IO;
229
using System.Linq;
330
using UnityEngine;
431

5-
/// <summary>
6-
/// Inventory distributed with the *.unitypackage in order to determine if there are any legacy files in need of removal
7-
/// </summary>
8-
internal sealed class OneSignalFileInventory : ScriptableObject
9-
{
32+
namespace OneSignalSDK {
1033
/// <summary>
11-
/// Array of paths within the OneSignal directory which were determined to be part of the distributed unitypackage
34+
/// Inventory distributed with the *.unitypackage in order to determine if there are any legacy files in need of removal
1235
/// </summary>
13-
public string[] DistributedPaths;
36+
internal sealed class OneSignalFileInventory : ScriptableObject {
37+
/// <summary>
38+
/// Array of paths within the OneSignal directory which were determined to be part of the distributed unitypackage
39+
/// </summary>
40+
public string[] DistributedPaths;
1441

15-
/// <summary>
16-
/// Array of current paths within the OneSignal directory
17-
/// </summary>
18-
public static string[] GetCurrentPaths()
19-
=> ConvertPathsToUnix(Directory.GetFiles(PackageAssetsPath, "*", SearchOption.AllDirectories));
42+
/// <summary>
43+
/// Array of current paths within the OneSignal directory
44+
/// </summary>
45+
public static string[] GetCurrentPaths()
46+
=> ConvertPathsToUnix(Directory.GetFiles(PackageAssetsPath, "*", SearchOption.AllDirectories));
2047

21-
/// <summary>
22-
/// Makes sure <see cref="paths"/> are using forward slash to be Unix compatible.
23-
/// https://docs.microsoft.com/en-us/dotnet/api/system.io.path.altdirectoryseparatorchar?view=net-5.0#examples
24-
/// </summary>
25-
/// <param name="paths">the paths to check and convert</param>
26-
/// <returns>paths with / as the directory separator</returns>
27-
public static string[] ConvertPathsToUnix(string[] paths) {
28-
if (Path.DirectorySeparatorChar == Path.AltDirectorySeparatorChar)
29-
return paths;
30-
31-
var fixedPaths = paths.Select(path =>
32-
path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
33-
);
48+
/// <summary>
49+
/// Makes sure <see cref="paths"/> are using forward slash to be Unix compatible.
50+
/// https://docs.microsoft.com/en-us/dotnet/api/system.io.path.altdirectoryseparatorchar?view=net-5.0#examples
51+
/// </summary>
52+
/// <param name="paths">the paths to check and convert</param>
53+
/// <returns>paths with / as the directory separator</returns>
54+
public static string[] ConvertPathsToUnix(string[] paths) {
55+
if (Path.DirectorySeparatorChar == Path.AltDirectorySeparatorChar)
56+
return paths;
3457

35-
return fixedPaths.ToArray();
36-
}
58+
var fixedPaths = paths.Select(path =>
59+
path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
60+
);
3761

38-
public const string AssetName = "OneSignalFileInventory.asset";
39-
public static readonly string PackageAssetsPath = Path.Combine("Assets", "OneSignal");
40-
public static readonly string EditorResourcesPath = Path.Combine(PackageAssetsPath, "Editor", "Resources");
41-
public static readonly string AssetPath = Path.Combine(EditorResourcesPath, AssetName);
62+
return fixedPaths.ToArray();
63+
}
64+
65+
public const string AssetName = "OneSignalFileInventory.asset";
66+
public static readonly string PackageAssetsPath = Path.Combine("Assets", "OneSignal");
67+
public static readonly string EditorResourcesPath = Path.Combine(PackageAssetsPath, "Editor", "Resources");
68+
public static readonly string AssetPath = Path.Combine(EditorResourcesPath, AssetName);
69+
}
4270
}
Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,74 @@
1-
using System.Collections.Generic;
1+
/*
2+
* Modified MIT License
3+
*
4+
* Copyright 2022 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
227

3-
/// <summary>
4-
/// Representation of the manifest file "dependency" entry.
5-
/// </summary>
6-
class Dependency
7-
{
8-
/// <summary>
9-
/// The dependency name.
10-
/// </summary>
11-
public string Name { get; }
28+
using System.Collections.Generic;
1229

30+
namespace OneSignalSDK {
1331
/// <summary>
14-
/// The dependency version.
32+
/// Representation of the manifest file "dependency" entry.
1533
/// </summary>
16-
public string Version { get; private set; }
34+
public class Dependency {
35+
/// <summary>
36+
/// The dependency name.
37+
/// </summary>
38+
public string Name { get; }
1739

18-
/// <summary>
19-
/// Initializes a new instance of the <see cref="Dependency"/> class with provided properties.
20-
/// </summary>
21-
/// <param name="name">Dependency name.</param>
22-
/// <param name="version">Dependency version.</param>
23-
public Dependency(string name, string version)
24-
{
25-
Name = name;
26-
Version = version;
27-
}
40+
/// <summary>
41+
/// The dependency version.
42+
/// </summary>
43+
public string Version { get; private set; }
2844

29-
/// <summary>
30-
/// Sets new dependency version.
31-
/// </summary>
32-
/// <param name="version">The version to be set for this dependency</param>
33-
public void SetVersion(string version)
34-
{
35-
Version = version;
36-
}
45+
/// <summary>
46+
/// Initializes a new instance of the <see cref="Dependency"/> class with provided properties.
47+
/// </summary>
48+
/// <param name="name">Dependency name.</param>
49+
/// <param name="version">Dependency version.</param>
50+
public Dependency(string name, string version) {
51+
Name = name;
52+
Version = version;
53+
}
3754

38-
/// <summary>
39-
/// Creates a dictionary from this object.
40-
/// </summary>
41-
/// <returns>Dependency object representation as Dictionary&lt;string, object&gt;.</returns>
42-
public Dictionary<string, object> ToDictionary()
43-
{
44-
Dictionary<string, object> result = new Dictionary<string, object>();
45-
result.Add(Name, Version);
46-
return result;
55+
/// <summary>
56+
/// Sets new dependency version.
57+
/// </summary>
58+
/// <param name="version">The version to be set for this dependency</param>
59+
public void SetVersion(string version) {
60+
Version = version;
61+
}
62+
63+
/// <summary>
64+
/// Creates a dictionary from this object.
65+
/// </summary>
66+
/// <returns>Dependency object representation as Dictionary&lt;string, object&gt;.</returns>
67+
public Dictionary<string, object> ToDictionary() {
68+
Dictionary<string, object> result = new Dictionary<string, object>();
69+
result.Add(Name, Version);
70+
71+
return result;
72+
}
4773
}
4874
}

0 commit comments

Comments
 (0)