You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
using System.Reflection; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using NUnit.Framework; |
|
using UnityEngine; |
|
using UnityEditor.Graphing; |
|
using UnityEditor.ShaderGraph.Internal; |
|
|
|
namespace UnityEditor.ShaderGraph.UnitTests |
|
{ |
|
[TestFixture] |
|
internal class NamespaceTests |
|
{ |
|
[Test] |
|
public void NoDanglingNamespaces() |
|
{ |
|
var myAssembly = Assembly.GetAssembly(typeof(AbstractMaterialNode)); |
|
HashSet<string> namespaces = new HashSet<string>(); |
|
foreach (var theType in myAssembly.GetTypes().Where(t => !string.IsNullOrEmpty(t.Namespace))) |
|
{ |
|
namespaces.Add(theType.Namespace); |
|
} |
|
var invalidNames = new List<string>(); |
|
foreach (var name in namespaces) |
|
{ |
|
if (name.Contains("ShaderGraph")) |
|
continue; |
|
if (name.Contains("UnityEditor")) |
|
continue; |
|
if (name.Contains("UnityEngine")) |
|
continue; |
|
|
|
invalidNames.Add(name); |
|
} |
|
Assert.IsEmpty(invalidNames, "The following namespaces are invalid for the Shader Graph package:\n" + string.Join("\n", invalidNames)); |
|
} |
|
} |
|
}
|
|
|