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

XProjectEnv base, MSBuild Properties helpers, and other relevant changes due to integration with vsSolutionBuildEvent #17

Merged
merged 4 commits into from
Aug 4, 2019
Merged
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
29 changes: 28 additions & 1 deletion MvsSln/Core/ConfigItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public IRuleOfConfig Rule
} = new RuleOfConfig();

/// <summary>
/// To use virtual `Sensitivity` method in comparing objects.
/// To use an `Sensitivity` logic when comparing {IConfPlatform}
/// together with `==` , `!=`.
/// </summary>
public bool SensitivityComparing
{
Expand All @@ -64,6 +65,10 @@ public string ConfigurationByRule
get => Rule?.Configuration(Configuration);
}

/// <summary>
/// {ConfigurationByRule} with optional case insensitive logic.
/// Uses {SensitivityComparing} flag.
/// </summary>
public string ConfigurationByRuleICase
{
get => Sensitivity(ConfigurationByRule);
Expand All @@ -80,11 +85,31 @@ public string PlatformByRule
get => Rule?.Platform(Platform);
}

/// <summary>
/// {PlatformByRule} with optional case insensitive logic.
/// Uses {SensitivityComparing} flag.
/// </summary>
public string PlatformByRuleICase
{
get => Sensitivity(PlatformByRule);
}

/// <summary>
/// Checking an config/platform by using {Rule} instance.
/// </summary>
/// <param name="config">Configuration name.</param>
/// <param name="platform">Platform name.</param>
/// <param name="icase">Case insensitive flag.</param>
/// <returns></returns>
public bool IsEqualByRule(string config, string platform, bool icase = false)
{
var cmp = icase ? StringComparison.InvariantCultureIgnoreCase
: StringComparison.InvariantCulture;

return string.Equals(ConfigurationByRule, Rule?.Configuration(config), cmp)
&& string.Equals(PlatformByRule, Rule?.Platform(platform), cmp);
}

public static bool operator ==(ConfigItem a, ConfigItem b)
{
return Object.ReferenceEquals(a, null) ?
Expand All @@ -104,6 +129,8 @@ public override bool Equals(object obj)

var b = (ConfigItem)obj;

// NOTE: {SensitivityComparing} will control an `Sensitivity` logic,
// thus we need only `...ByRuleICase` properties:
return ConfigurationByRuleICase == b.ConfigurationByRuleICase
&& PlatformByRuleICase == b.PlatformByRuleICase;
}
Expand Down
67 changes: 54 additions & 13 deletions MvsSln/Core/Guids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,69 @@

using System.Collections.Generic;
using System.Linq;
using net.r_eg.MvsSln.Extensions;

// TODO: move to '.Types' namespace and split ProjectType processing into new additional type.
namespace net.r_eg.MvsSln.Core
{
public static class Guids
{
/// <summary>
/// Solution Folder.
/// </summary>
public const string SLN_FOLDER = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";
public const string SLN_FOLDER = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";

public const string PROJECT_CS = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
public const string PROJECT_DB = "{C8D11400-126E-41CD-887F-60BD40844F9E}";
public const string PROJECT_FS = "{F2A71F9B-5D33-465A-A702-920D77279786}";
public const string PROJECT_VB = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}";
public const string PROJECT_VC = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
public const string PROJECT_VJ = "{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}";
public const string PROJECT_WD = "{2CFEAB61-6A3B-4EB8-B523-560B4BEEF521}";
public const string PROJECT_WEB = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}";
/// <summary>
/// .csproj
/// </summary>
public const string PROJECT_CS = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";

/// <summary>
/// .dbproj
/// </summary>
public const string PROJECT_DB = "{C8D11400-126E-41CD-887F-60BD40844F9E}";

/// <summary>
/// .fsproj
/// </summary>
public const string PROJECT_FS = "{F2A71F9B-5D33-465A-A702-920D77279786}";

/// <summary>
/// .vbproj
/// </summary>
public const string PROJECT_VB = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}";

/// <summary>
/// .vcxproj
/// </summary>
public const string PROJECT_VC = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";

/// <summary>
/// .vjsproj
/// </summary>
public const string PROJECT_VJ = "{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}";

/// <summary>
/// .wdproj
/// </summary>
public const string PROJECT_WD = "{2CFEAB61-6A3B-4EB8-B523-560B4BEEF521}";

/// <summary>
///
/// </summary>
public const string PROJECT_WEB = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}";

/// <summary>
/// .deployproj
/// </summary>
public const string PROJECT_DEPLOY = "{151D2E53-A2C4-4D7D-83FE-D05416EBD58E}";
public const string PROJECT_SF = "{A07B5EB6-E848-4116-A8D0-A826331D98C6}";

private static Dictionary<ProjectType, string> ProjectTypeGuids = new Dictionary<ProjectType, string>()
/// <summary>
/// .sfproj
/// </summary>
public const string PROJECT_SF = "{A07B5EB6-E848-4116-A8D0-A826331D98C6}";

private static Dictionary<ProjectType, string> projectTypeGuids = new Dictionary<ProjectType, string>()
{
{ ProjectType.Cs, PROJECT_CS },
{ ProjectType.Db, PROJECT_DB },
Expand All @@ -69,7 +110,7 @@ public static class Guids
/// <returns></returns>
public static ProjectType ProjectTypeBy(string guid)
{
return ProjectTypeGuids.FirstOrDefault(p => p.Value == guid).Key;
return projectTypeGuids.FirstOrDefault(p => p.Value == guid).Key;
}

/// <summary>
Expand All @@ -79,7 +120,7 @@ public static ProjectType ProjectTypeBy(string guid)
/// <returns></returns>
public static string GuidBy(ProjectType type)
{
return ProjectTypeGuids[type];
return projectTypeGuids.GetOrDefault(type);
}
}
}
20 changes: 19 additions & 1 deletion MvsSln/Core/IConfPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,38 @@ public interface IConfPlatform
IRuleOfConfig Rule { get; }

/// <summary>
/// To use virtual `Sensitivity` method to compare objects.
/// To use an `Sensitivity` logic when comparing {IConfPlatform}
/// together with `==` , `!=`.
/// </summary>
bool SensitivityComparing { get; set; }

string Configuration { get; }

string ConfigurationByRule { get; }

/// <summary>
/// {ConfigurationByRule} with optional case insensitive logic.
/// Uses {SensitivityComparing} flag.
/// </summary>
string ConfigurationByRuleICase { get; }

string Platform { get; }

string PlatformByRule { get; }

/// <summary>
/// {PlatformByRule} with optional case insensitive logic.
/// Uses {SensitivityComparing} flag.
/// </summary>
string PlatformByRuleICase { get; }

/// <summary>
/// Checking an config/platform by using {Rule} instance.
/// </summary>
/// <param name="config">Configuration name.</param>
/// <param name="platform">Platform name.</param>
/// <param name="icase">Case insensitive flag.</param>
/// <returns></returns>
bool IsEqualByRule(string config, string platform, bool icase = false);
}
}
99 changes: 1 addition & 98 deletions MvsSln/Core/IEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,110 +24,13 @@
*/

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Build.Evaluation;

namespace net.r_eg.MvsSln.Core
{
[Guid("818233C6-5BFE-47D5-929D-668C70EA25D5")]
public interface IEnvironment: IDisposable
public interface IEnvironment: IXProjectEnv, IDisposable
{
/// <summary>
/// Access to Solution data.
/// </summary>
ISlnResult Sln { get; }

/// <summary>
/// List of all evaluated projects at current time
/// with unique configuration for each instance.
/// </summary>
IEnumerable<IXProject> Projects { get; }

/// <summary>
/// List of evaluated projects that filtered by Guid.
/// </summary>
IEnumerable<IXProject> UniqueByGuidProjects { get; }

/// <summary>
/// Access to GlobalProjectCollection
/// </summary>
ProjectCollection PrjCollection { get; }

/// <summary>
/// Find project by Guid.
/// </summary>
/// <param name="guid">Guid of project.</param>
/// <param name="cfg">Specific configuration.</param>
/// <returns></returns>
IXProject XProjectByGuid(string guid, IConfPlatform cfg);

/// <summary>
/// Find project by Guid.
/// </summary>
/// <param name="guid">Guid of project.</param>
/// <returns></returns>
IXProject[] XProjectsByGuid(string guid);

/// <summary>
/// Find projects by name.
/// </summary>
/// <param name="name">ProjectName.</param>
/// <param name="cfg">Specific configuration.</param>
/// <returns></returns>
IXProject[] XProjectsByName(string name, IConfPlatform cfg);

/// <summary>
/// Find projects by name.
/// </summary>
/// <param name="name">ProjectName.</param>
/// <returns></returns>
IXProject[] XProjectsByName(string name);

/// <summary>
/// Get or firstly load into collection the project.
/// Use default configuration.
/// </summary>
/// <param name="pItem">Specific project.</param>
/// <returns></returns>
Project GetOrLoadProject(ProjectItem pItem);

/// <summary>
/// Get or firstly load into collection the project.
/// </summary>
/// <param name="pItem">Specific project.</param>
/// <param name="conf">Configuration of project to load.</param>
/// <returns></returns>
Project GetOrLoadProject(ProjectItem pItem, IConfPlatform conf);

/// <summary>
/// Get or firstly load into collection the project.
/// </summary>
/// <param name="pItem">Specific project.</param>
/// <param name="properties"></param>
/// <returns></returns>
Project GetOrLoadProject(ProjectItem pItem, IDictionary<string, string> properties);

/// <summary>
/// Get project properties from solution properties.
/// </summary>
/// <param name="pItem"></param>
/// <param name="slnProps">Solution properties.</param>
/// <returns></returns>
IDictionary<string, string> GetProjectProperties(ProjectItem pItem, IDictionary<string, string> slnProps);

/// <summary>
/// Load available projects via configurations.
/// It will be added without unloading of previous.
/// </summary>
/// <param name="pItems">Specific list or null value to load all available.</param>
/// <returns>Loaded projects.</returns>
IEnumerable<IXProject> LoadProjects(IEnumerable<ProjectItemCfg> pItems = null);

/// <summary>
/// Load the only one configuration for each available project.
/// </summary>
/// <returns>Loaded projects.</returns>
IEnumerable<IXProject> LoadMinimalProjects();
}
}
6 changes: 6 additions & 0 deletions MvsSln/Core/ISlnResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public interface ISlnResult
/// </summary>
string SolutionDir { get; }

/// <summary>
/// Full path to an solution file.
/// </summary>
string SolutionFile { get; }

/// <summary>
/// Processed type for result.
/// </summary>
Expand Down Expand Up @@ -81,6 +86,7 @@ public interface ISlnResult

/// <summary>
/// All available global properties for solution.
/// Use optional {PropertyNames} to access to popular properties.
/// </summary>
RoProperties Properties { get; }

Expand Down
Loading