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

Conversation

3F
Copy link
Owner

@3F 3F commented Jul 16, 2019

Introduces XProjectEnv (spitted IsolatedEnv as the base but without IDisposable)

+ 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

…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
@3F
Copy link
Owner Author

3F commented Jul 16, 2019

IsolatedEnv still implements IDisposable that helps to release loaded projects as before.

But for some cases we don't need to dispose this at all.

The case is, for example, vssbe. Where EnvDTE can load any other project itself while loading something through EnvDTE.Project collection.

Therefore, we also need to provide like XProjectEnv base for work with this environment 'as is'.
Means that user can also consider some additional resource releasing later.

Please note, the default behavior for Sln wrapper still is IsolatedEnv. That is, this is compatible changes.

3F added 3 commits July 29, 2019 21:04
…sSolutionBuildEvent:

3F/vsSolutionBuildEvent#53
#17

## IConfPlatform changes:

+`bool IsEqualByRule(string config, string platform, bool icase = false);`

    Checking an config/platform by using {Rule} instance.

## IXProjectEnv changes:

+`IXProject XProjectByFile(...);`

    Find project by full path to file.

+`IEnumerable<IXProject> Assign(IEnumerable<Project> projects = null);`

    Assign an existing `Microsoft.Build.Evaluation.Project` instances for local collection.

+`IXProject AddOrGet(Project project);`

    Adds `Microsoft.Build.Evaluation.Project` instance into IXProject collection if it does not exist.

+`ProjectItemCfg ExtractItemCfg(Project project);`

    Prepares data from `Microsoft.Build.Evaluation.Project` instance.

+`void UnloadAll(bool throwIfErr = true);`

    Unloads all evaluated projects at current time.

+`bool Unload(IXProject xp);`

    Unloads specified project.

+`IEnumerable<Project> ValidProjects`

    List of valid projects such as something except `.user` but contains FirstChild / LastChild XML node.

## ISlnResult changes:

+`string SolutionFile`

    Full path to an solution file.

## New extension methods:

```
+TVal GetOrDefault<TKey, TVal>(this IDictionary<TKey, TVal> data, TKey key, TVal def)
+bool IsEqual(this Project a, Project b)
+string GetSolutionDir(this Project eProject)
+string GetProjectRelativePath(this Project eProject)
+string GetConfig(this Project eProject)
+string GetPlatform(this Project eProject)
+string GetSolutionExt(this Project eProject)
```

## Other

* Removed pGuid checking from `IXProjectEnv.GetOrLoadProject()`
* Added `FileExt` type for work with `ProjectType` via its file only.
also added method extensions:

* `bool Remove<T>(this IList<T> src, T elem, Func<T, T, bool> comparer)`
* `bool IsLimEqual(this IXProject x, IXProject prj)`

and added .metaproj filter for an `IXProjectEnv.ValidProjects` property
@3F 3F changed the title WIP. XProjectEnv base and helpers for MSBuild Properties. /vsSBE PR53 XProjectEnv base, MSBuild Properties helpers, and other relevant changes due to integration with vsSolutionBuildEvent Aug 4, 2019
@3F 3F merged commit 7d7fb00 into master Aug 4, 2019
@3F 3F deleted the support/vssbe/pr53 branch August 4, 2019 18:04
3F added a commit that referenced this pull request Aug 10, 2019
* FIXED: "The format ... of configuration is not supported". Issue #19.

* FIXED: Fixed loading of projects via `IsolatedEnv.LoadProjects()`.

* FIXED: Fixed possible NullReferenceException in `ProjectItem` constructors.

* NEW: Introduces XProjectEnv. PR #17.
       An splitted IsolatedEnv as the base but without IDisposable.
    ```
    IXProjectEnv slnEnv;
    ...
    slnEnv = new XProjectEnv(sln, properties);
    ...
    slnEnv = new IsolatedEnv(sln); // +IEnvironment, +IDisposable
    slnEnv.Assign();
    ...
    ((IDisposable)slnEnv)?.Dispose();
    ```

* NEW: Added `PropertyNames` type. Regular MSBuild Properties and related.

* NEW: Added `FileExt` type for work with `ProjectType` via its file only.

* NEW: Added `Kinds` type: PRJ_UNLOADED; PRJ_SLN_DIR

* NEW: New extension methods:
    ```
    +TVal GetOrDefault<TKey, TVal>(this IDictionary<TKey, TVal> data, TKey key, TVal def)
    +bool IsEqual(this Project a, Project b)
    +string GetSolutionDir(this Project eProject)
    +string GetProjectRelativePath(this Project eProject)
    +string GetConfig(this Project eProject)
    +string GetPlatform(this Project eProject)
    +string GetSolutionExt(this Project eProject)
    string GetDirectoryFromFile(this string file)
    Dictionary<string, string> GetFileProperties(this string file)
    IDictionary<string, string> AddOrUpdate(this IDictionary<string, string> source, IDictionary<string, string> items)
    bool Remove<T>(this IList<T> src, T elem, Func<T, T, bool> comparer)
    bool IsLimEqual(this IXProject x, IXProject prj)
    ```

* CHANGED: Removed pGuid checking from `IXProjectEnv.GetOrLoadProject()`
           Related to Issue #18.

* CHANGED: ISlnResult changes:
    ```
    +`string SolutionFile`
        Full path to an solution file.
        Old versions still can address it through Properties.
    ```

* CHANGED: IConfPlatform changes:
    ```
    +`bool IsEqualByRule(string config, string platform, bool icase = false);`
        Checking an config/platform by using {Rule} instance.
    ```

* CHANGED: IXProjectEnv (IEnvironment) changes:
    ```
    +`IXProject XProjectByFile(...);`
        Find project by full path to file.

    +`IEnumerable<IXProject> Assign(IEnumerable<Project> projects = null);`
        Assign an existing `Microsoft.Build.Evaluation.Project` instances for local collection.

    +`IXProject AddOrGet(Project project);`
        Adds `Microsoft.Build.Evaluation.Project` instance into IXProject collection if it does not exist.

    +`ProjectItemCfg ExtractItemCfg(Project project);`
        Prepares data from `Microsoft.Build.Evaluation.Project` instance.

    +`void UnloadAll(bool throwIfErr = true);`
        Unloads all evaluated projects at current time.

    +`bool Unload(IXProject xp);`
        Unloads specified project.

    +`IEnumerable<Project> ValidProjects`
        List of valid projects such as something except `.user`,`.metaproj` but contains FirstChild / LastChild XML node.
    ```

* CHANGED: Updated package's tool hMSBuild 2.2

           Release notes:
           https://github.com/3F/hMSBuild/releases/tag/v2.2

* NOTE: The most 2.4 changes is relevant to integration with vsSolutionBuildEvent.

        https://twitter.com/GitHub3F/status/1158091930309398528
        3F/vsSolutionBuildEvent#53
        #17

        Find any relevant use of the new features in that project.
@3F 3F mentioned this pull request Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant