Skip to content

Commit

Permalink
Introduces XProjectEnv (spitted IsolatedEnv as the base but without I…
Browse files Browse the repository at this point in the history
…Disposable)

+ Also adds an regular MSBuild Properties and other related changes for convenient work with this properties like extension method GetFileProperties, AddOrUpdate etc.

Part of 3F/vsSolutionBuildEvent#53
WIP
  • Loading branch information
3F committed Jul 16, 2019
1 parent be6418a commit 684cdb4
Show file tree
Hide file tree
Showing 13 changed files with 716 additions and 452 deletions.
1 change: 1 addition & 0 deletions MvsSln/Core/Guids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Collections.Generic;
using System.Linq;

// TODO: move to '.Types' namespace
namespace net.r_eg.MvsSln.Core
{
public static class Guids
Expand Down
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();
}
}
133 changes: 133 additions & 0 deletions MvsSln/Core/IXProjectEnv.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013-2019 Denis Kuzmin < entry.reg@gmail.com > GitHub/3F
* Copyright (c) MvsSln contributors: https://github.com/3F/MvsSln/graphs/contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

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

namespace net.r_eg.MvsSln.Core
{
[Guid("1BED7620-25A0-4FC3-BD44-A284782CA68A")]
public interface IXProjectEnv
{
/// <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();
}
}
Loading

0 comments on commit 684cdb4

Please sign in to comment.