Skip to content

Commit

Permalink
Centralize PA name (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Trivellato authored and GitHub Enterprise committed Nov 20, 2023
1 parent 69798bc commit 247e793
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
18 changes: 10 additions & 8 deletions Editor/API/ProjectAuditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public sealed class ProjectAuditor

internal const string k_PackageName = "com.unity.project-auditor";

public const string DisplayName = "Project Auditor";

internal static string PackagePath
{
get
Expand Down Expand Up @@ -138,7 +140,7 @@ public void AuditAsync(AnalysisParams analysisParams, IProgress progress = null)
if (!BuildPipeline.IsBuildTargetSupported(BuildPipeline.GetBuildTargetGroup(platform), platform))
{
// Error and early out if the user has request analysis of a platform which the Unity Editor doesn't have installed support for
Debug.LogError($"Build target {platform} is not supported in this Unity Editor");
Debug.LogError($"[{ProjectAuditor.DisplayName}] Build target {platform} is not supported in this Unity Editor");
analysisParams.OnCompleted(report);
return;
}
Expand Down Expand Up @@ -171,7 +173,7 @@ public void AuditAsync(AnalysisParams analysisParams, IProgress progress = null)
{
var moduleEndTime = DateTime.Now;
if (logTimingsInfo)
Debug.Log($"Project Auditor module {module.Name} took: " +
Debug.Log($"[{ProjectAuditor.DisplayName}] Module {module.Name} analysis took: " +
(moduleEndTime - moduleStartTime).TotalMilliseconds / 1000.0 + " seconds.");

report.RecordModuleInfo(module, moduleStartTime, moduleEndTime);
Expand All @@ -183,7 +185,7 @@ public void AuditAsync(AnalysisParams analysisParams, IProgress progress = null)
{
stopwatch.Stop();
if (logTimingsInfo)
Debug.Log("Project Auditor took: " + stopwatch.ElapsedMilliseconds / 1000.0f +
Debug.Log($"[{ProjectAuditor.DisplayName}] Analysis took: " + stopwatch.ElapsedMilliseconds / 1000.0f +
" seconds.");

analysisParams.OnCompleted?.Invoke(report);
Expand All @@ -197,13 +199,13 @@ public void AuditAsync(AnalysisParams analysisParams, IProgress progress = null)
}
catch (Exception e)
{
Debug.LogError($"Project Auditor module {module.Name} failed: " + e.Message + " " + e.StackTrace);
Debug.LogError($"[{ProjectAuditor.DisplayName}] Module {module.Name} failed: " + e.Message + " " + e.StackTrace);
moduleParams.OnModuleCompleted();
}
}

if (logTimingsInfo)
Debug.Log("Project Auditor time to interactive: " + stopwatch.ElapsedMilliseconds / 1000.0f + " seconds.");
Debug.Log($"[{ProjectAuditor.DisplayName}] Time to interactive: " + stopwatch.ElapsedMilliseconds / 1000.0f + " seconds.");
}

/// <summary>
Expand All @@ -220,9 +222,9 @@ public void OnPreprocessBuild(BuildReport report)
if (numIssues > 0)
{
if (UserPreferences.FailBuildOnIssues)
Debug.LogError("Project Auditor found " + numIssues + " issues");
Debug.LogError($"[{ProjectAuditor.DisplayName}] Analysis found " + numIssues + " issues");
else
Debug.Log("Project Auditor found " + numIssues + " issues");
Debug.Log($"[{ProjectAuditor.DisplayName}] Analysis found " + numIssues + " issues");
}
}
}
Expand Down Expand Up @@ -303,7 +305,7 @@ void InitModules()
}
catch (Exception e)
{
Debug.LogError($"Project Auditor [{instance.Name}]: {e.Message} {e.StackTrace}");
Debug.LogError($"{DisplayName} [{instance.Name}]: {e.Message} {e.StackTrace}");
continue;
}
m_Modules.Add(instance);
Expand Down
2 changes: 1 addition & 1 deletion Editor/ProjectAuditorSettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static SettingsProvider CreateSettingsProvider()
var provider = new SettingsProvider("Project/ProjectAuditor", SettingsScope.Project)
{
// By default the last token of the path is used as display name if no label is provided.
label = "Project Auditor",
label = ProjectAuditor.DisplayName,
// Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
guiHandler = SettingsGUI,

Expand Down
2 changes: 1 addition & 1 deletion Editor/UI/CompilerMessagesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CompilerMessagesView : AnalysisView
const string k_Info = @"This view shows compiler error, warning and info messages.
To view Roslyn Analyzer diagnostics, make sure Roslyn Analyzer DLLs use the <b>RoslynAnalyzer</b> label.";
const string k_RoslynDisabled = "The UseRoslynAnalyzers option is disabled. To enable Roslyn diagnostics reporting, make sure the corresponding option is enabled in Preferences > Analysis > Project Auditor.";
const string k_RoslynDisabled = "The UseRoslynAnalyzers option is disabled. To enable Roslyn diagnostics reporting, make sure the corresponding option is enabled in Preferences > Analysis > " + ProjectAuditor.DisplayName + ".";
const string k_NotAvailable = "This view is not available when 'CompilationMode' is set to 'CompilationMode.Editor'.";

bool m_ShowInfo;
Expand Down
4 changes: 2 additions & 2 deletions Editor/UI/Framework/ViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void Create(SeverityRules rules, ViewStates viewStates, Action<ViewDescri
var desc = ViewDescriptor.GetAll().FirstOrDefault(d => d.category == category);
if (desc == null)
{
Debug.LogWarning("[Project Auditor] Descriptor for " + ProjectAuditor.GetCategoryName(category) + " was not registered.");
Debug.LogWarning($"[{ProjectAuditor.DisplayName}] Descriptor for " + ProjectAuditor.GetCategoryName(category) + " was not registered.");
continue;
}
var layout = IssueLayout.GetLayout(category);
Expand All @@ -102,7 +102,7 @@ public void Create(SeverityRules rules, ViewStates viewStates, Action<ViewDescri

if (!isSupported)
{
Debug.LogWarning("[Project Auditor] Layout for category " + ProjectAuditor.GetCategoryName(category) + " was not found.");
Debug.LogWarning($"[{ProjectAuditor.DisplayName}] Layout for category " + ProjectAuditor.GetCategoryName(category) + " was not found.");
continue;
}

Expand Down
22 changes: 10 additions & 12 deletions Editor/UI/ProjectAuditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ enum ProjectAreaFlags

const ProjectAreaFlags k_ProjectAreaDefaultFlags = ProjectAreaFlags.Code | ProjectAreaFlags.Settings | ProjectAreaFlags.Build;

const string k_ProjectAuditorName = "Project Auditor";

static readonly string[] AreaNames = Enum.GetNames(typeof(Areas)).Where(a => a != "None" && a != "All").ToArray();
static ProjectAuditorWindow s_Instance;

Expand Down Expand Up @@ -1286,7 +1284,7 @@ void DrawViewSelection()
if (category != IssueCategory.Metadata && !m_ProjectReport.HasCategory(category))
{
var displayName = m_ViewManager.GetView(category).Desc.displayName;
if (!EditorUtility.DisplayDialog(k_ProjectAuditorName,
if (!EditorUtility.DisplayDialog(ProjectAuditor.DisplayName,
$"'{displayName}' analysis will now begin.", "Ok",
"Cancel"))
return; // do not analyze and change view
Expand Down Expand Up @@ -1544,7 +1542,7 @@ void DrawTabs()
{
var tab = m_Tabs[tabToAudit];

if (EditorUtility.DisplayDialog(k_ProjectAuditorName,
if (EditorUtility.DisplayDialog(ProjectAuditor.DisplayName,
$"'{tab.name}' analysis will now begin.", "Ok", "Cancel"))
{
AuditCategories(tab.allCategories, true);
Expand Down Expand Up @@ -1661,11 +1659,11 @@ static void OpenPreferences()
var preferencesWindow = SettingsService.OpenUserPreferences(UserPreferences.Path);
if (preferencesWindow == null)
{
Debug.LogError($"Could not find Preferences for 'Analysis/{k_ProjectAuditorName}'");
Debug.LogError($"Could not find Preferences for 'Analysis/{ProjectAuditor.DisplayName}'");
}
}

[MenuItem("Window/Analysis/" + k_ProjectAuditorName)]
[MenuItem("Window/Analysis/" + ProjectAuditor.DisplayName)]
public static ProjectAuditorWindow ShowWindow()
{
var wnd = GetWindow(typeof(ProjectAuditorWindow)) as ProjectAuditorWindow;
Expand Down Expand Up @@ -1695,7 +1693,7 @@ static class LayoutSize

static class Contents
{
public static readonly GUIContent WindowTitle = new GUIContent(k_ProjectAuditorName);
public static readonly GUIContent WindowTitle = new GUIContent(ProjectAuditor.DisplayName);

public static readonly GUIContent AnalyzeButton =
new GUIContent("Analyze", "Analyze Project and list all issues found.");
Expand All @@ -1714,7 +1712,7 @@ static class Contents
public static readonly GUIContent DiscardButton = Utility.GetIcon(Utility.IconType.Trash, "Discard the current report.");

public static readonly GUIContent HelpButton = Utility.GetIcon(Utility.IconType.Help, "Open Manual (in a web browser)");
public static readonly GUIContent PreferencesMenuItem = EditorGUIUtility.TrTextContent("Preferences", $"Open User Preferences for {k_ProjectAuditorName}");
public static readonly GUIContent PreferencesMenuItem = EditorGUIUtility.TrTextContent("Preferences", $"Open User Preferences for {ProjectAuditor.DisplayName}");

public static readonly GUIContent AssemblyFilter =
new GUIContent("Assembly : ", "Select assemblies to examine");
Expand All @@ -1730,19 +1728,19 @@ static class Contents

public static readonly GUIContent FiltersFoldout = new GUIContent("Filters", "Filtering Criteria");

public static readonly GUIContent WelcomeTextTitle = new GUIContent("Welcome to Project Auditor");
public static readonly GUIContent WelcomeTextTitle = new GUIContent($"Welcome to {ProjectAuditor.DisplayName}");

public static readonly GUIContent WelcomeText = new GUIContent(
@"
Project Auditor is a static analysis tool that analyzes assets, settings, and scripts of the Unity project and produces a report that contains the following:
$@"
{ProjectAuditor.DisplayName} is a static analysis tool that analyzes assets, settings, and scripts of the Unity project and produces a report that contains the following:
• <b>Diagnostics</b>: a list of possible problems that might affect performance, memory and other areas.
• <b>BuildReport</b>: timing and size information of the last build.
• <b>Assets information</b>
To Analyze the project, click on <b>Analyze</b>.
Once the project is analyzed, Project Auditor displays a summary with high-level information. Then, it is possible to dive into a specific section of the report from the View menu.
Once the project is analyzed, {ProjectAuditor.DisplayName} displays a summary with high-level information. Then, it is possible to dive into a specific section of the report from the View menu.
A view allows the user to browse through the listed items and filter by string or other search criteria.
"
Expand Down
2 changes: 1 addition & 1 deletion Editor/UI/SummaryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void DrawSessionInfo(SessionInfo sessionInfo)
new KeyValuePair<string, string>("Project Name", sessionInfo.ProjectName),
new KeyValuePair<string, string>("Project Revision", sessionInfo.ProjectRevision),
new KeyValuePair<string, string>("Unity Version", sessionInfo.UnityVersion),
new KeyValuePair<string, string>("Project Auditor Version", sessionInfo.ProjectAuditorVersion)
new KeyValuePair<string, string>($"{ProjectAuditor.DisplayName} Version", sessionInfo.ProjectAuditorVersion)
};

DrawSessionFields("Session Information", keyValues);
Expand Down

0 comments on commit 247e793

Please sign in to comment.