Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small readability tweaks #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions SlowCheetah.VisualStudio/NugetHandler/SlowCheetahNuGetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ private static bool IsOldSlowCheetahInstalled(IVsBuildPropertyStorage buildPrope
{
string propertyValue;
buildPropertyStorage.GetPropertyValue("SlowCheetahImport", null, (uint)_PersistStorageType.PST_PROJECT_FILE, out propertyValue);
if (!string.IsNullOrEmpty(propertyValue))
var propertyValueIsPopulated = !string.IsNullOrEmpty(propertyValue);
if (propertyValueIsPopulated)
{
return true;
}

buildPropertyStorage.GetPropertyValue("SlowCheetahTargets", null, (uint)_PersistStorageType.PST_PROJECT_FILE, out propertyValue);
if (!string.IsNullOrEmpty(propertyValue))
propertyValueIsPopulated = !string.IsNullOrEmpty(propertyValue);
if (propertyValueIsPopulated)
{
return true;
}
Expand Down Expand Up @@ -153,7 +155,8 @@ private void BackgroundInstallSlowCheetah(Project project)

if (needInstall)
{
if (this.HasUserAcceptedWarningMessage(Resources.Resources.NugetInstall_Title, Resources.Resources.NugetInstall_Text))
var userHasAcceptedWarningMessage = this.HasUserAcceptedWarningMessage(Resources.Resources.NugetInstall_Title, Resources.Resources.NugetInstall_Text);
if (userHasAcceptedWarningMessage)
{
// Gets the general output pane to inform user of installation
IVsOutputWindowPane outputWindow = (IVsOutputWindowPane)this.package.GetService(typeof(SVsGeneralOutputWindowPane));
Expand Down Expand Up @@ -202,7 +205,8 @@ private void UpdateSlowCheetah(Project project)
// This is done on the UI thread because changes are made to the project file,
// causing it to be reloaded. To avoid conflicts with NuGet installation,
// the update is done sequentially
if (this.HasUserAcceptedWarningMessage(Resources.Resources.NugetUpdate_Title, Resources.Resources.NugetUpdate_Text))
var userHasAcceptedWarningMessage = this.HasUserAcceptedWarningMessage(Resources.Resources.NugetUpdate_Title, Resources.Resources.NugetUpdate_Text);
if (userHasAcceptedWarningMessage)
{
// Creates dialog informing the user to wait for the installation to finish
IVsThreadedWaitDialogFactory twdFactory = this.package.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;
Expand Down
26 changes: 15 additions & 11 deletions SlowCheetah.VisualStudio/SlowCheetahPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,7 @@ private void OnAddTransformCommand(object sender, EventArgs e)
string content = this.BuildXdtContent(itemFullPath);
IEnumerable<string> configs = ProjectUtilities.GetProjectConfigurations(selectedProjectItem.ContainingProject);

List<string> transformsToCreate = null;
if (configs != null)
{
transformsToCreate = configs.ToList();
}

if (transformsToCreate == null)
{
transformsToCreate = new List<string>();
}
List<string> transformsToCreate = GetTransformsFromConfigs(configs);

// if it is a web project we should add publish profile specific transforms as well
var publishProfileTransforms = this.GetPublishProfileTransforms(hierarchy, projectFullPath);
Expand All @@ -398,6 +389,18 @@ private void OnAddTransformCommand(object sender, EventArgs e)
}
}

private List<string> GetTransformsFromConfigs(IEnumerable<string> configs)
{
if (configs == null)
{
return new List<string>();
}
else
{
return configs.ToList();
}
}

/// <summary>
/// This function is the callback used to execute a command when the a menu item is clicked.
/// See the Initialize method to see how the menu item is associated to this function using
Expand Down Expand Up @@ -622,7 +625,8 @@ private bool ProjectSupportsTransforms(IVsProject project)

foreach (string supportedExtension in ProjectUtilities.GetSupportedProjectExtensions((IVsSettingsManager)this.GetService(typeof(SVsSettingsManager))))
{
if (projectExtension.Equals(supportedExtension, StringComparison.InvariantCultureIgnoreCase))
var extensionIsSupported = projectExtension.Equals(supportedExtension, StringComparison.InvariantCultureIgnoreCase);
if (extensionIsSupported)
{
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion SlowCheetah.VisualStudio/Utilities/PackageUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public static bool IsFileTransform(string documentName, string transformName, IE
return false;
}

if (!Path.GetExtension(documentName).Equals(Path.GetExtension(transformName), StringComparison.OrdinalIgnoreCase))
var documentTypeMatchesTransformType = Path.GetExtension(documentName).Equals(Path.GetExtension(transformName), StringComparison.OrdinalIgnoreCase);
var documentTypeDoesNotMatchTransformType = !documentTypeMatchesTransformType;
if (documentTypeDoesNotMatchTransformType)
{
return false;
}
Expand Down