Skip to content

Commit

Permalink
Merge pull request #45 from dotBunny/dev
Browse files Browse the repository at this point in the history
Release  1.2.7
  • Loading branch information
reapazor authored Mar 17, 2021
2 parents 235539f + 0f4b807 commit ca72b2b
Show file tree
Hide file tree
Showing 59 changed files with 3,676 additions and 909 deletions.
7 changes: 7 additions & 0 deletions .docfx/manual/contributing/design-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ There is a general effort to follow the [Framework Design Guidelines](https://do
## Coding Conventions
[.NET Coding Conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions) is also a good point of reference.

## Unit Tests
We are trying to get as much coverage in tests as possible on the package to try and mitigate regressions. Please have a read of [Unit Testing Best Practices](https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices).

> Arrange, Act, Assert


## Code Organization
- Typically sections of classes are ordered alphabetically.
- Preference to expose backing data, indices, etc.
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.7] - 2021-03-16
***"Never Say Never"***
> Updates have been tested across different installation methods, a pooling system, and some fixes!
### Added
- UPM and GitHub installation methods utilizing the`dev` branch will have a "Force Update" action available to them in the **Project Settings**.
- `PlatformExtensions` now has a `IsHeadless()` method for determining if the application is running without a graphics device initialized; aka a headless server.
- `EnumExtensions` has a faster `HasFlags()` method for working with flags.
- `PoolingSystem` now exists in the `GDX.Collections.Pooling` namespace, including a `GameObjectPool` system.
- `Trace` static now available to funnel all `GDX` based logging through, with editor/build configurations available.

### Changed
- Made `SparseSets` .NET Standard 2.0 compliant [@godjammit](https://github.com/dotBunny/GDX/pull/41)

### Fixed
- Caught issue with `initialCapcity` causing an OOB issue with `SparseSets` [@godjammit](https://github.com/dotBunny/GDX/pull/41)
- Caught a few more null coalescing assignments that are not compatible with Unity 2019 in `InspectorMessageBoxAttributeDecoratorDrawer`. (thanks Nick & Gabe)
- Resolved `PackageProvider` issues with Unity 2019.

## [1.2.6] - 2021-02-15
***"UPM Updates"***
> Starting to frame up the ability to update package adds from GitHub.
Expand Down
40 changes: 40 additions & 0 deletions CodeCoverage.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>GDX.dll</ModulePath>
<ModulePath>GDX.Editor.dll</ModulePath>
</Include>
<Exclude>
<ModulePath>GDX.Tests.EditMode.dll</ModulePath>
<ModulePath>GDX.Tests.PlayMode.dll</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^*Attribute$</Attribute>
<!-- <Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute> -->
</Exclude>
</Attributes>
<Functions>
<Exclude>
<Function>^GDX\.*Extensions\.cctor$</Function>
<Function>^GDX\.GDXConfig\..ctor$</Function>
<Function>^GDX\.GDXConfig\..cctor$</Function>
<Function>^GDX\.Developer\.CommandLineParser\..cctor$</Function>
</Exclude>
</Functions>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
7 changes: 7 additions & 0 deletions CodeCoverage.runsettings.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion GDX/Editor/Build/BuildInfoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static void WriteDefaultFile()
}
catch (Exception e)
{
Debug.LogWarning(e);
Trace.Output(Trace.TraceLevel.Warning, e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion GDX/Editor/Build/Classic/BuildInfoBuildCustomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public override void OnBeforeBuild()
}
catch (Exception e)
{
Debug.LogWarning(e);
Trace.Output(Trace.TraceLevel.Warning, e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion GDX/Editor/Build/Legacy/BuildInfoBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void OnPreprocessBuild(BuildReport report)
}
catch (Exception e)
{
Debug.LogWarning(e);
Trace.Output(Trace.TraceLevel.Warning, e);
}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ public class InspectorMessageBoxAttributeDecoratorDrawer : DecoratorDrawer
/// <returns>The height in pixels.</returns>
public override float GetHeight()
{
_target ??= (InspectorMessageBoxAttribute)attribute;
_targetMessage ??= new GUIContent(_target.Message);
// ReSharper disable once ConvertIfStatementToNullCoalescingAssignment
if (_target == null)
{
_target = (InspectorMessageBoxAttribute)attribute;
}
// ReSharper disable once ConvertIfStatementToNullCoalescingAssignment
if (_targetMessage == null)
{
_targetMessage = new GUIContent(_target.Message);
}
return s_cachedHelpBoxStyle.CalcHeight(_targetMessage, EditorGUIUtility.currentViewWidth) + 4;
}

Expand All @@ -44,7 +52,12 @@ public override float GetHeight()
/// <param name="position">Rectangle on the screen to use for the decorator.</param>
public override void OnGUI(Rect position)
{
_target ??= (InspectorMessageBoxAttribute)attribute;
// ReSharper disable once ConvertIfStatementToNullCoalescingAssignment
if (_target == null)
{
_target = (InspectorMessageBoxAttribute)attribute;
}

switch (_target.MessageType)
{
case InspectorMessageBoxAttribute.MessageBoxType.Info:
Expand Down
23 changes: 22 additions & 1 deletion GDX/Editor/PackageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using System;
using System.IO;
using System.Reflection;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.PlayerLoop;

// ReSharper disable MemberCanBePrivate.Global

Expand Down Expand Up @@ -203,7 +205,12 @@ public static void EnsureScriptingDefineSymbol()
continue;
}

PlayerSettings.GetScriptingDefineSymbolsForGroup(group, out string[] defines);
string[] defines = null;
#if UNITY_2020_1_OR_NEWER
PlayerSettings.GetScriptingDefineSymbolsForGroup(group, out defines);
#else
defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group).Split(';');
#endif
int location = defines.FirstIndexOfItem("GDX");

// Found
Expand All @@ -217,7 +224,21 @@ public static void EnsureScriptingDefineSymbol()
string[] newDefines = new string[oldLength + 1];
Array.Copy(defines, newDefines, oldLength);
newDefines[oldLength] = "GDX";


#if UNITY_2020_2_OR_NEWER
PlayerSettings.SetScriptingDefineSymbolsForGroup(@group, newDefines);
#else
StringBuilder output = new StringBuilder();
foreach (string s in newDefines)
{
output.Append(s);
output.Append(";");
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(group,output.ToString().TrimEnd(new[] {';'}));
#endif


}
}

Expand Down
71 changes: 68 additions & 3 deletions GDX/Editor/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,27 @@ private static class Content
/// </summary>
public static readonly GUIContent TestPassedIcon;

/// <summary>
/// Settings content for <see cref="GDXConfig.traceDevelopmentLevels" />.
/// </summary>
public static readonly GUIContent TraceDevelopmentLevels = new GUIContent(
"Development Tracing",
"The levels of trace call to be logged in a development/editor build.");

/// <summary>
/// Settings content for <see cref="GDXConfig.traceDebugLevels" />.
/// </summary>
public static readonly GUIContent TraceDebugLevels = new GUIContent(
"Debug Tracing",
"The levels of trace call to be logged in a debug build.");

/// <summary>
/// Settings content for <see cref="GDXConfig.traceReleaseLevels" />.
/// </summary>
public static readonly GUIContent TraceReleaseLevels = new GUIContent(
"Release Tracing",
"The levels of trace call to be logged in a release build.");

/// <summary>
/// Initialize the <see cref="Content" />.
/// </summary>
Expand Down Expand Up @@ -512,7 +533,8 @@ public static void AutomaticUpdates(SerializedObject settings)
GUILayout.Label("Source Branch:", EditorStyles.boldLabel,
Styles.FixedWidth130LayoutOptions);
GUILayout.Label(!string.IsNullOrEmpty(UpdateProvider.LocalPackage.SourceTag)
? UpdateProvider.LocalPackage.SourceTag : "N/A");
? UpdateProvider.LocalPackage.SourceTag
: "N/A");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
break;
Expand All @@ -522,7 +544,8 @@ public static void AutomaticUpdates(SerializedObject settings)
GUILayout.Label("Source Tag:", EditorStyles.boldLabel,
Styles.FixedWidth130LayoutOptions);
GUILayout.Label(!string.IsNullOrEmpty(UpdateProvider.LocalPackage.SourceTag)
? UpdateProvider.LocalPackage.SourceTag : "N/A");
? UpdateProvider.LocalPackage.SourceTag
: "N/A");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
break;
Expand All @@ -532,7 +555,8 @@ public static void AutomaticUpdates(SerializedObject settings)
GUILayout.Label("Source Commit:", EditorStyles.boldLabel,
Styles.FixedWidth130LayoutOptions);
GUILayout.Label(!string.IsNullOrEmpty(UpdateProvider.LocalPackage.SourceTag)
? UpdateProvider.LocalPackage.SourceTag : "N/A");
? UpdateProvider.LocalPackage.SourceTag
: "N/A");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
break;
Expand Down Expand Up @@ -581,6 +605,19 @@ public static void AutomaticUpdates(SerializedObject settings)
{
UpdateProvider.CheckForUpdates();
}

// Special allowance to force pull dev branch to avoid having to increment the version code.
if ((UpdateProvider.LocalPackage.InstallationMethod ==
PackageProvider.InstallationType.GitHubBranch ||
UpdateProvider.LocalPackage.InstallationMethod ==
PackageProvider.InstallationType.UPMBranch) &&
UpdateProvider.LocalPackage.SourceTag == "dev")
{
if (GUILayout.Button("Force Upgrade", Styles.ButtonStyle))
{
UpdateProvider.AttemptUpgrade(true);
}
}
}

EditorGUILayout.EndVertical();
Expand Down Expand Up @@ -736,6 +773,34 @@ public static void Environment(SerializedObject settings)

EditorGUILayout.PropertyField(settings.FindProperty("environmentScriptingDefineSymbol"),
Content.EnvironmentScriptingDefineSymbol);


SerializedProperty developmentLevelsProperty = settings.FindProperty("traceDevelopmentLevels");
EditorGUI.BeginChangeCheck();
ushort newDevelopmentLevels = (ushort)EditorGUILayout.MaskField(Content.TraceDevelopmentLevels, developmentLevelsProperty.intValue,
developmentLevelsProperty.enumDisplayNames);
if (EditorGUI.EndChangeCheck())
{
developmentLevelsProperty.intValue = newDevelopmentLevels;
}

SerializedProperty debugLevelsProperty = settings.FindProperty("traceDebugLevels");
EditorGUI.BeginChangeCheck();
ushort newDebugLevels = (ushort)EditorGUILayout.MaskField(Content.TraceDebugLevels, debugLevelsProperty.intValue,
debugLevelsProperty.enumDisplayNames);
if (EditorGUI.EndChangeCheck())
{
debugLevelsProperty.intValue = newDebugLevels;
}

SerializedProperty releaseLevelsProperty = settings.FindProperty("traceReleaseLevels");
EditorGUI.BeginChangeCheck();
ushort newReleaseLevels = (ushort)EditorGUILayout.MaskField(Content.TraceReleaseLevels, releaseLevelsProperty.intValue,
releaseLevelsProperty.enumDisplayNames);
if (EditorGUI.EndChangeCheck())
{
releaseLevelsProperty.intValue = newReleaseLevels;
}
}

/// <summary>
Expand Down
28 changes: 7 additions & 21 deletions GDX/Editor/UpdateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ public static bool HasUpdate(PackageProvider.PackageDefinition updatePackageDefi
/// <summary>
/// Attempt to do the upgrade of the package based on the established <see cref="PackageProvider.InstallationType" />.
/// </summary>
public static void AttemptUpgrade()
/// <param name="forceUpgrade">Should we bypass all safety checks?</param>
public static void AttemptUpgrade(bool forceUpgrade = false)
{
string messageStart =
$"There is a new version of GDX available ({UpdatePackageDefinition.version}).\n";
if (!IsUpgradable())
if (!forceUpgrade && !IsUpgradable())
{
EditorUtility.DisplayDialog("GDX Update Available",
$"{messageStart}Unfortunately we are unable to determine a proper upgrade path for your package. We are UNABLE to upgrade your package for you automatically.",
Expand Down Expand Up @@ -313,7 +314,7 @@ private static void UpgradeAssetDatabase()
catch (Exception e)
{
// We will end up here if the formulated Uri is bad.
Debug.LogWarning(e.Message);
Trace.Output(Trace.TraceLevel.Warning, e.Message);
return;
}
finally
Expand Down Expand Up @@ -422,16 +423,16 @@ private static void UpgradeGitHub()
}

/// <summary>
/// Removes the com.dotbunny.gdx entry from the Manifest Lockfile, forcing the package manager to
/// reset what version the package is currently at.
/// Upgrade the package, with the understanding that it was added via UPM.
/// </summary>
public static void RemovePackageManifestLockFileEntry()
private static void UpgradeUnityPackageManager()
{
// We're going to remove the entry from the lockfile triggering it to record an update
string packageManifestLockFile =
Path.Combine(Application.dataPath.Substring(0, Application.dataPath.Length - 6), "Packages",
"packages-lock.json");

// We can only do this if the file exists!
if (File.Exists(packageManifestLockFile))
{
string[] lockFileContents = File.ReadAllLines(packageManifestLockFile);
Expand Down Expand Up @@ -474,20 +475,5 @@ public static void RemovePackageManifestLockFileEntry()
}
}
}

/// <summary>
/// Upgrade the package, with the understanding that it was added via UPM.
/// </summary>
private static void UpgradeUnityPackageManager()
{
// Delete the cached package if found
string cacheFolderPath = Path.Combine(Application.dataPath.Substring(0, Application.dataPath.Length - 6),
"Library", "PackageCache");

// Remove entry from lock file
RemovePackageManifestLockFileEntry();

// Do we need to delete the actual folder?
}
}
}
Loading

0 comments on commit ca72b2b

Please sign in to comment.