Skip to content

Commit 102de27

Browse files
committed
reading GUIDs from assembly definition files now correctly and added assembly def tests
1 parent d1983c0 commit 102de27

8 files changed

Lines changed: 94 additions & 4 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "NikosHelpersSampleTestAssemblyA",
3+
"references": [],
4+
"includePlatforms": [
5+
"Editor"
6+
],
7+
"excludePlatforms": [],
8+
"allowUnsafeCode": false,
9+
"overrideReferences": false,
10+
"precompiledReferences": [],
11+
"autoReferenced": true,
12+
"defineConstraints": [],
13+
"versionDefines": [],
14+
"noEngineReferences": false
15+
}

Assets/NikosAssets/U3DHelperTools/Samples/Resources/RegenerateGUIDFolder/NikosHelpersSampleTestAssemblyA.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "NikosHelpersSampleTestAssembly",
3+
"references": [
4+
"GUID:8defb84a4b37da54580d6848b395ecb8"
5+
],
6+
"includePlatforms": [
7+
"Editor"
8+
],
9+
"excludePlatforms": [],
10+
"allowUnsafeCode": false,
11+
"overrideReferences": false,
12+
"precompiledReferences": [],
13+
"autoReferenced": true,
14+
"defineConstraints": [],
15+
"versionDefines": [],
16+
"noEngineReferences": false
17+
}

Assets/NikosAssets/U3DHelperTools/Samples/Resources/RegenerateGUIDFolder/Recursive/NikosHelpersSampleTestAssemblyB.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class TestForGUIDRegen : MonoBehaviour
6+
{
7+
// Start is called before the first frame update
8+
void Start()
9+
{
10+
11+
}
12+
13+
// Update is called once per frame
14+
void Update()
15+
{
16+
17+
}
18+
}

Assets/NikosAssets/U3DHelperTools/Samples/Resources/RegenerateGUIDFolder/Recursive/TestForGUIDRegen.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/NikosAssets/U3DHelperTools/Samples/Scenes/Demo_EditorAndGUI.unity

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ MonoBehaviour:
221221
events."
222222
fileNameToReplace: _RENAME_TEST_2
223223
desiredFileName: _RENAME_TEST_1
224+
regenGuidsRecursive: 1
225+
acceptedMetaFilesForGuidRegen: 0
224226
pathChosen: Assets/NikosAssets/U3DHelperTools/Samples/Resources/
225227
scriptClassAndFileName: GeneratedScriptTest2
226228
scriptMethodName: CallMe

Assets/NikosAssets/U3DHelperTools/Scripts/Editor/GUIDHelper.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ public enum AcceptedMetaFiles
9393
private static bool IsAcceptedMetaFile(string isInLocalDirectory, string filePath, bool recursive,
9494
AcceptedMetaFiles acceptedMetaFiles, string[] whiteListExtensions)
9595
{
96-
string directory = Path.GetDirectoryName(filePath).Replace(@"\", "/") + "/";
97-
9896
if (!Path.GetExtension(filePath).Equals(".meta")) return false;
97+
98+
string directory = Path.GetDirectoryName(filePath).Replace(@"\", "/") + "/";
9999

100100
//any meta file
101101
bool isAccepted = true;
@@ -409,18 +409,31 @@ public static void RegenerateGuids(
409409
}
410410
}
411411

412+
public static List<string> GetGuidsFromFileContents(string fileContents)
413+
{
414+
List<string> guids = new List<string>();
415+
416+
//also checks for "GUID: ", "GUID:", "guid: "
417+
string fileContentsSimple = fileContents.ToLower().Replace(" ", "");
418+
guids.AddRange(GetGuidsFromFileContents(fileContentsSimple, "guid:"));
419+
420+
return guids;
421+
}
422+
412423
/// <summary>
413424
/// Return found GUIDs of the given file contents (text/ string)
414425
/// </summary>
415426
/// <param name="fileContents">
416427
/// The string contents of a file
417428
/// </param>
429+
/// <param name="guidStart">
430+
/// Search for the GUID prefix
431+
/// </param>
418432
/// <returns>
419433
/// A list of found GUID strings
420434
/// </returns>
421-
public static List<string> GetGuidsFromFileContents(string fileContents)
435+
public static List<string> GetGuidsFromFileContents(string fileContents, string guidStart)
422436
{
423-
const string guidStart = "guid: ";
424437
const int guidLength = 32;
425438
int textLength = fileContents.Length;
426439
int guidStartLength = guidStart.Length;

0 commit comments

Comments
 (0)