public void IssueInMonoBehaviourUpdate() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetIssueInMonoBehaviourUpdate); var issue = issues.First(); Assert.True(issue.isPerfCriticalContext); }
public void LinqIssueIsReported() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAsset); Assert.AreEqual(1, issues.Count()); var myIssue = issues.FirstOrDefault(); Assert.NotNull(myIssue); Assert.NotNull(myIssue.descriptor); Assert.AreEqual(Rule.Severity.Default, myIssue.descriptor.severity); Assert.AreEqual(101049, myIssue.descriptor.id); Assert.True(myIssue.descriptor.type.Equals("System.Linq")); Assert.True(myIssue.descriptor.method.Equals("*")); Assert.True(myIssue.name.Equals("Enumerable.Count")); Assert.True(myIssue.filename.Equals(m_TempAsset.scriptName)); Assert.True(myIssue.description.Equals("Enumerable.Count")); Assert.True( myIssue.GetCallingMethod().Equals( "System.Int32 MyClass::Dummy(System.Collections.Generic.List`1<System.Int32>)")); Assert.AreEqual(9, myIssue.line); Assert.AreEqual(IssueCategory.Code, myIssue.category); }
public void IssueIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAsset); Assert.AreEqual(1, issues.Count()); var myIssue = issues.FirstOrDefault(); Assert.NotNull(myIssue); Assert.NotNull(myIssue.descriptor); Assert.AreEqual(Rule.Action.Default, myIssue.descriptor.action); Assert.AreEqual(101000, myIssue.descriptor.id); Assert.True(myIssue.descriptor.type.Equals("UnityEngine.Camera")); Assert.True(myIssue.descriptor.method.Equals("main")); Assert.True(myIssue.name.Equals("Camera.get_main")); Assert.True(myIssue.filename.Equals(m_TempAsset.scriptName)); Assert.True(myIssue.description.Equals("UnityEngine.Camera.main")); Assert.True(myIssue.callingMethod.Equals("System.Void MyClass::Dummy()")); Assert.AreEqual(8, myIssue.line); Assert.AreEqual(IssueCategory.Code, myIssue.category); // check custom property Assert.AreEqual((int)CodeProperty.Num, myIssue.GetNumCustomProperties()); Assert.True(myIssue.GetCustomProperty((int)CodeProperty.Assembly).Equals(AssemblyHelper.DefaultAssemblyName)); }
public void ShouldNotReportMutedIssue() { var projectAuditor = new Unity.ProjectAuditor.Editor.ProjectAuditor(); var projectAuditorSettings = projectAuditor.config; var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAsset); Assert.AreEqual(1, issues.Count()); var issue = issues.FirstOrDefault(); projectAuditorSettings.ClearAllRules(); var action = projectAuditorSettings.GetAction(issue.descriptor, issue.callingMethod); // expect default action specified in descriptor Assert.AreEqual(issue.descriptor.severity, action); // add rule with a filter. projectAuditorSettings.AddRule(new Rule { id = issue.descriptor.id, severity = Rule.Severity.None, filter = issue.callingMethod }); action = projectAuditorSettings.GetAction(issue.descriptor, issue.callingMethod); // issue has been muted so it should not be reported Assert.AreEqual(Rule.Severity.None, action); }
public void BoxingFloatValueIsReported() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetBoxingFloat); Assert.AreEqual(1, issues.Count()); var boxingFloat = issues.FirstOrDefault(); // check issue Assert.NotNull(boxingFloat); Assert.True(boxingFloat.name.Equals("BoxingFloatTest.Dummy")); Assert.True(boxingFloat.filename.Equals(m_TempAssetBoxingFloat.scriptName)); Assert.True(boxingFloat.description.Equals("Conversion from value type 'float' to ref type")); Assert.True(boxingFloat.callingMethod.Equals("System.Object BoxingFloatTest::Dummy()")); Assert.AreEqual(1, boxingFloat.line); Assert.AreEqual(IssueCategory.Code, boxingFloat.category); // check descriptor Assert.NotNull(boxingFloat.descriptor); Assert.AreEqual(Rule.Action.Default, boxingFloat.descriptor.action); Assert.AreEqual(102000, boxingFloat.descriptor.id); Assert.True(string.IsNullOrEmpty(boxingFloat.descriptor.type)); Assert.True(string.IsNullOrEmpty(boxingFloat.descriptor.method)); Assert.False(string.IsNullOrEmpty(boxingFloat.descriptor.description)); Assert.True(boxingFloat.descriptor.description.Equals("Boxing Allocation")); }
public void BoxingIntValueIsReported() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceBoxingInt); Assert.AreEqual(1, issues.Count()); var boxingInt = issues.FirstOrDefault(); // check issue Assert.NotNull(boxingInt); Assert.True(boxingInt.name.Equals("BoxingIntTest.Start")); Assert.True(boxingInt.filename.Equals(m_ScriptResourceBoxingInt.scriptName)); Assert.True(boxingInt.description.Equals("Conversion from value type 'Int32' to ref type")); Assert.True(boxingInt.callingMethod.Equals("System.Void BoxingIntTest::Start()")); Assert.AreEqual(1, boxingInt.line); Assert.AreEqual(IssueCategory.ApiCalls, boxingInt.category); // check descriptor Assert.NotNull(boxingInt.descriptor); Assert.AreEqual(Rule.Action.Default, boxingInt.descriptor.action); Assert.AreEqual(102000, boxingInt.descriptor.id); Assert.True(string.IsNullOrEmpty(boxingInt.descriptor.type)); Assert.True(string.IsNullOrEmpty(boxingInt.descriptor.method)); Assert.False(string.IsNullOrEmpty(boxingInt.descriptor.description)); Assert.True(boxingInt.descriptor.description.Equals("Boxing Allocation")); }
public void IssueInSimpleClass() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetIssueInSimpleClass); var issue = issues.First(); Assert.False(issue.isPerfCriticalContext); }
public void IssueInMonoBehaviourIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceIssueInMonoBehaviour); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void MyMonoBehaviour::Start()")); }
public void StringConcatIssueIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceStringConcat); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().description.Equals("System.String.Concat")); }
public void AddComponentIssueIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetAddComponent); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void AddComponentToGameObject::Start()")); }
public void InstantiateIssueIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetInstantiate); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void InstantiateObject::Start()")); }
public void IssueInVirtualMethodIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetIssueInVirtualMethod); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void AbstractClass::Dummy()")); }
public void IssueInGenericClassIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetIssueInGenericClass); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void GenericClass`1::Dummy()")); }
public void IssueInOverrideMethodIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceIssueInOverrideMethod); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void DerivedClass::Dummy()")); }
public void IssueInPlayerCodeIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceInPlayerCode); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void MyClassWithPlayerOnlyCode::Dummy()")); }
public void IssueInPluginIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceInPlugin); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Void MyPlugin::Dummy()")); }
public void IssueInDelegateIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceIssueInDelegate); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Int32 ClassWithDelegate/<>c::<Dummy>b__1_0()")); }
public void IssueInCoroutineIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceIssueInCoroutine); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().callingMethod.Equals("System.Boolean MyMonoBehaviourWithCoroutine/<MyCoroutine>d__1::MoveNext()")); }
public void IssueInNestedClassIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetIssueInNestedClass); Assert.AreEqual(1, issues.Count()); Assert.True(issues.First().GetCallingMethod().Equals("System.Void MyClassWithNested/NestedClass::Dummy()")); }
public void IssueInNamespaceIsFound() { var allScriptIssues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetAnyApiInNamespace); var issue = allScriptIssues.FirstOrDefault(i => i.description.Equals("Enumerable.Sum")); Assert.NotNull(issue); Assert.True(issue.descriptor.description.Equals("System.Linq.*")); }
public void ShaderWarmupIssueIsCritical() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues( m_TempAssetShaderWarmupIssueIsCritical); var issue = issues.First(); Assert.True(issue.isPerfCriticalContext); }
public void IssueInClassMethodCalledFromMonoBehaviourUpdate() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues( m_ScriptResourceIssueInClassMethodCalledFromMonoBehaviourUpdate); var issue = issues.First(); Assert.True(issue.isPerfCriticalContext); }
public void IssueInDelegateIsFound() { var allScriptIssues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetIssueInDelegate); var issue = allScriptIssues.FirstOrDefault(i => i.name.Equals("Camera.get_main")); Assert.NotNull(issue); Assert.True(issue.callingMethod.Equals("System.Int32 ClassWithDelegate/<>c::<Dummy>b__1_0()")); }
public void IssueInClassInheritedFromMonoBehaviour() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues( m_TempAssetIssueInClassInheritedFromMonoBehaviour); var issue = issues.First(); Assert.True(issue.isPerfCriticalContext); }
public void DerivedClassMethodIssueIsFound() { var filteredIssues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetDerivedClassMethod); Assert.AreEqual(1, filteredIssues.Count()); var myIssue = filteredIssues.FirstOrDefault(); Assert.NotNull(myIssue); Assert.NotNull(myIssue.descriptor); Assert.True(myIssue.description.Equals("UnityEngine.Component.tag")); }
public void ObjectAllocationIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceObjectAllocation); Assert.AreEqual(1, issues.Count()); var allocationIssue = issues.FirstOrDefault(); Assert.NotNull(allocationIssue); Assert.True(allocationIssue.description.Equals("'ObjectAllocation' object allocation")); Assert.AreEqual(IssueCategory.ApiCalls, allocationIssue.category); }
public void MultidimensionalArrayAllocationIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_TempAssetMultidimensionalArrayAllocation); Assert.AreEqual(1, issues.Count()); var allocationIssue = issues.FirstOrDefault(); Assert.NotNull(allocationIssue); Assert.True(allocationIssue.description.Equals("'Int32[0...,0...]' object allocation")); Assert.AreEqual(IssueCategory.Code, allocationIssue.category); }
public void ArrayAllocationIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResourceArrayAllocation); Assert.AreEqual(1, issues.Count()); var allocationIssue = issues.FirstOrDefault(); Assert.NotNull(allocationIssue); Assert.True(allocationIssue.description.Equals("'Int32' array allocation")); Assert.AreEqual(IssueCategory.Code, allocationIssue.category); }
public void MonoBehaviourWithEmptyMagicMethodIsReported() { var scriptIssues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_MonoBehaviourWithEmptyMagicMethod); Assert.AreEqual(1, scriptIssues.Count()); var issue = scriptIssues.FirstOrDefault(); Assert.NotNull(issue); Assert.NotNull(issue.descriptor); Assert.AreEqual(Rule.Severity.Default, issue.descriptor.severity); Assert.AreEqual(EmptyMethodAnalyzer.GetDescriptor().id, issue.descriptor.id); Assert.True(string.IsNullOrEmpty(issue.descriptor.type)); Assert.True(string.IsNullOrEmpty(issue.descriptor.method)); Assert.True(issue.name.Equals("MonoBehaviourWithEmptyMagicMethod.Update")); Assert.True(issue.filename.Equals(m_MonoBehaviourWithEmptyMagicMethod.scriptName)); Assert.True(issue.description.Equals("System.Void MonoBehaviourWithEmptyMagicMethod::Update()")); Assert.True(issue.GetCallingMethod().Equals("System.Void MonoBehaviourWithEmptyMagicMethod::Update()")); Assert.AreEqual(1, issue.line); Assert.AreEqual(IssueCategory.Code, issue.category); }
public void IssueIsFound() { var issues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_ScriptResource); Assert.AreEqual(1, issues.Count()); var myIssue = issues.FirstOrDefault(); Assert.NotNull(myIssue); Assert.NotNull(myIssue.descriptor); Assert.AreEqual(Rule.Action.Default, myIssue.descriptor.action); Assert.AreEqual(101000, myIssue.descriptor.id); Assert.True(myIssue.descriptor.type.Equals("UnityEngine.Camera")); Assert.True(myIssue.descriptor.method.Equals("main")); Assert.True(myIssue.name.Equals("Camera.get_main")); Assert.True(myIssue.filename.Equals(m_ScriptResource.scriptName)); Assert.True(myIssue.description.Equals("UnityEngine.Camera.main")); Assert.True(myIssue.callingMethod.Equals("System.Void MyClass::Dummy()")); Assert.AreEqual(8, myIssue.line); Assert.AreEqual(IssueCategory.ApiCalls, myIssue.category); }