public void SetUp() { m_ScriptResourceBoxingInt = new ScriptResource("BoxingIntTest.cs", "using UnityEngine; class BoxingIntTest : MonoBehaviour { void Start() { Debug.Log(\"The number of the beast is: \" + 666); } }"); m_ScriptResourceBoxingFloat = new ScriptResource("BoxingFloatTest.cs", "using UnityEngine; class BoxingFloatTest : MonoBehaviour { void Start() { Debug.Log(\"The number of the beast is: \" + 666.0f); } }"); m_ScriptResourceBoxingGenericRefType = new ScriptResource("BoxingGenericRefType.cs", "using UnityEngine; class SomeClass {}; class BoxingGenericRefType<T> where T : SomeClass { T refToGenericType; void Start() { if (refToGenericType == null){} } }"); m_ScriptResourceBoxingGeneric = new ScriptResource("BoxingGeneric.cs", "using UnityEngine; class BoxingGeneric<T> { T refToGenericType; void Start() { if (refToGenericType == null){} } }"); }
public static IEnumerable <ProjectIssue> AnalyzeAndFindScriptIssues(ScriptResource scriptResource) { var projectAuditor = new Unity.ProjectAuditor.Editor.ProjectAuditor(); var projectReport = projectAuditor.Audit(); return(ScriptAuditor.FindScriptIssues(projectReport, scriptResource.relativePath)); }
public void SetUp() { m_ScriptResourceInstantiate = new ScriptResource("InstantiateObject.cs", @" using UnityEngine; class InstantiateObject : MonoBehaviour { public GameObject Prefab; public GameObject Instance; void Start() { Instance = Instantiate(Prefab); } } "); m_ScriptResourceAddComponent = new ScriptResource("AddComponentToGameObject.cs", @" using UnityEngine; class AddComponentToGameObject : MonoBehaviour { public GameObject Instance; void Start() { Instance.AddComponent<Rigidbody>(); } } "); }
public void SetUp() { m_MonoBehaviourWithEmptyMagicMethod = new ScriptResource("MonoBehaviourWithEmptyMagicMethod.cs", "using UnityEngine; class MyBaseClass : MonoBehaviour { } class MonoBehaviourWithEmptyMagicMethod : MyBaseClass { void Update() { } }"); m_MonoBehaviourWithEmptyMethod = new ScriptResource("MonoBehaviourWithEmptyMethod.cs", "using UnityEngine; class MonoBehaviourWithEmptyMethod : MonoBehaviour{ void NotMagicMethod() { } }"); m_NotMonoBehaviourWithEmptyMethod = new ScriptResource("NotMonoBehaviourWithEmptyMethod.cs", "class NotMonoBehaviourWithEmptyMethod { void Update() { } }"); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", @" class MyClass { #if !UNITY_EDITOR asd #endif } "); }
public void SetUp() { m_ScriptResourceBoxingInt = new ScriptResource("BoxingIntTest.cs", "using System; class BoxingIntTest { Object Dummy() { return 666; } }"); m_ScriptResourceBoxingFloat = new ScriptResource("BoxingFloatTest.cs", "using System; class BoxingFloatTest { Object Dummy() { return 666.0f; } }"); m_ScriptResourceBoxingGenericRefType = new ScriptResource("BoxingGenericRefType.cs", "class SomeClass {}; class BoxingGenericRefType<T> where T : SomeClass { T refToGenericType; void Dummy() { if (refToGenericType == null){} } }"); m_ScriptResourceBoxingGeneric = new ScriptResource("BoxingGeneric.cs", "class BoxingGeneric<T> { T refToGenericType; void Dummy() { if (refToGenericType == null){} } }"); }
public void SetUp() { m_ScriptResourceObjectAllocation = new ScriptResource("ObjectAllocation.cs", @" class ObjectAllocation { static ObjectAllocation Dummy() { // explicit object allocation return new ObjectAllocation(); } } "); m_ScriptResourceArrayAllocation = new ScriptResource("ArrayAllocation.cs", @" class ArrayAllocation { int[] array; void Dummy() { // explicit array allocation array = new int[1]; } } "); m_ScriptResourceMultidimensionalArrayAllocation = new ScriptResource("MultidimensionalArrayAllocation.cs", @" class MultidimensionalArrayAllocation { int[,] array; void Dummy() { // explicit array allocation array = new int[1,1]; } } "); m_ScriptResourceParamsArrayAllocation = new ScriptResource("ParamsArrayAllocation.cs", @" class ParamsArrayAllocation { void DummyImpl(params object[] args) { } void Dummy(object C) { // implicit array allocation DummyImpl(null, null); } } "); }
public void SetUp() { m_ScriptResourceStringConcat = new ScriptResource("StringConcat.cs", @" class StringConcat { string text; string Dummy() { return text + text; } } "); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", @" using UnityEngine; class MyClass { void Dummy() { // Accessing Camera.main property is not recommended and will be reported as a possible performance problem. Debug.Log(Camera.main.name); } } "); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", @" using System.Linq; using System.Collections.Generic; class MyClass { int Dummy(List<int> list) { return list.Count(); } }" ); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", @" using UnityEngine; class MyClass { void Dummy() { #if UNITY_EDITOR Debug.Log(Camera.main.name); #endif } } "); }
public void SetUp() { m_ShaderResource = new ScriptResource("Resources/MyTestShader.shader", @" Shader ""Custom/MyTestShader"" { Properties { _Color (""Color"", Color) = (1,1,1,1) } SubShader { Tags { ""RenderType""=""Opaque"" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _Color; void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack ""Diffuse"" } "); }
public void SetUp() { m_ScriptResource = new ScriptResource("FilterTests.cs", @" using UnityEngine; class WrapperClass { InternalClass impl; void DoSomething() { impl.DoSomething(); } } class InternalClass { public void DoSomething() { // Accessing Camera.main property is not recommended and will be reported as a possible performance problem. Debug.Log(Camera.main.name); } } "); }
public void SetUp() { // this is required so the default assembly is generated m_ScriptResource = new ScriptResource("MyClass.cs", "class MyClass { }"); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", "using UnityEngine; class MyClass : MonoBehaviour { void Start() { Debug.Log(Camera.main.name); } }"); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", @" using UnityEngine; class MyClass { void Dummy() { // Accessing Camera.main property is not recommended and will be reported as a possible performance problem. Debug.Log(Camera.main.name); } } "); m_ScriptResourceInPlayerCode = new ScriptResource("IssueInPlayerCode.cs", @" using UnityEngine; class MyClassWithPlayerOnlyCode { void Dummy() { #if !UNITY_EDITOR Debug.Log(Camera.main.name); #endif } } "); m_ScriptResourceInEditorCode = new ScriptResource("IssueInEditorCode.cs", @" using UnityEngine; class MyClassWithEditorOnlyCode { void Dummy() { #if UNITY_EDITOR Debug.Log(Camera.main.name); #endif } } "); m_ScriptResourceIssueInNestedClass = new ScriptResource("IssueInNestedClass.cs", @" using UnityEngine; class MyClassWithNested { class NestedClass { void Dummy() { Debug.Log(Camera.main.name); } } } "); m_ScriptResourceIssueInGenericClass = new ScriptResource("IssueInGenericClass.cs", @" using UnityEngine; class GenericClass<T> { void Dummy() { Debug.Log(Camera.main.name); } } "); m_ScriptResourceIssueInVirtualMethod = new ScriptResource("IssueInVirtualMethod.cs", @" using UnityEngine; abstract class AbstractClass { public virtual void Dummy() { Debug.Log(Camera.main.name); } } "); m_ScriptResourceIssueInOverrideMethod = new ScriptResource("IssueInOverrideMethod.cs", @" using UnityEngine; class BaseClass { public virtual void Dummy() { } } class DerivedClass : BaseClass { public override void Dummy() { Debug.Log(Camera.main.name); } } "); m_ScriptResourceIssueInMonoBehaviour = new ScriptResource("IssueInMonoBehaviour.cs", @" using UnityEngine; class MyMonoBehaviour : MonoBehaviour { void Start() { Debug.Log(Camera.main.name); } } "); m_ScriptResourceIssueInCoroutine = new ScriptResource("IssueInCoroutine.cs", @" using UnityEngine; using System.Collections; class MyMonoBehaviourWithCoroutine : MonoBehaviour { void Start() { StartCoroutine(MyCoroutine()); } IEnumerator MyCoroutine() { yield return 1; } } "); m_ScriptResourceIssueInDelegate = new ScriptResource("IssueInDelegate.cs", @" using UnityEngine; using System; class ClassWithDelegate { private Func<int> myFunc; void Dummy() { myFunc = () => { Debug.Log(Camera.main.name); return 0; }; } } "); }
public void SetUp() { m_ScriptResourceIssueInSimpleClass = new ScriptResource("IssueInSimpleClass.cs", @" using UnityEngine; class IssueInSimpleClass { void Dummy() { // Accessing Camera.main property is not recommended and will be reported as a possible performance problem. Debug.Log(Camera.main.name); } } "); m_ScriptResourceIssueInMonoBehaviourUpdate = new ScriptResource("IssueInMonoBehaviourUpdate.cs", @" using UnityEngine; class IssueInMonoBehaviourUpdate : MonoBehaviour { void Update() { Debug.Log(Camera.main.name); } } "); m_ScriptResourceIssueInClassMethodCalledFromMonoBehaviourUpdate = new ScriptResource( "IssueInClassMethodCalledFromMonoBehaviourUpdate.cs", @" using UnityEngine; class IssueInClassMethodCalledFromMonoBehaviourUpdate : MonoBehaviour { class NestedClass { public void Dummy() { // Accessing Camera.main property is not recommended and will be reported as a possible performance problem. Debug.Log(Camera.main.name); } } NestedClass m_MyObj; void Update() { m_MyObj.Dummy(); } } "); m_ScriptResourceIssueInClassInheritedFromMonoBehaviour = new ScriptResource( "IssueInClassInheritedFromMonoBehaviour.cs", @" using UnityEngine; class A : MonoBehaviour { } class B : A { void Update() { Debug.Log(Camera.main.name); } } "); }
public void SetUp() { m_ScriptResource = new ScriptResource("MyClass.cs", "using UnityEngine;using System.Linq;using System.Collections.Generic; struct Test{public int i;}class MyClass : MonoBehaviour { int Dummy() { var list = new List<Test>(); return list.Count(); } }"); }