You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-16 15:30:08 +00:00
com.unity.ide.visualstudio@2.0.0
## [2.0.0] - 2019-11-06 - Improved Visual Studio and Visual Studio for Mac automatic discovery - Added support for the VSTU messaging system (start/stop features from Visual Studio) - Added support for solution roundtrip (preserves references to external projects and solution properties) - Added support for VSTU Analyzers (requires Visual Studio 2019 16.3, Visual Studio for Mac 8.3) - Added a warning when using legacy pdb symbol files. - Fixed issues while Opening Visual Studio on Windows - Fixed issues while Opening Visual Studio on Mac ## [1.1.1] - 2019-05-29 Fix Bridge assembly loading with non VS2017 editors ## [1.1.0] - 2019-05-27 Move internal extension handling to package.
This commit is contained in:
80
Editor/SolutionParser.cs
Normal file
80
Editor/SolutionParser.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Microsoft.Unity.VisualStudio.Editor
|
||||
{
|
||||
internal static class SolutionParser
|
||||
{
|
||||
// Compared to the bridge implementation, we are not returning "{" "}" from Guids
|
||||
private static readonly Regex ProjectDeclaration = new Regex(@"Project\(\""{(?<projectFactoryGuid>.*?)}\""\)\s+=\s+\""(?<name>.*?)\"",\s+\""(?<fileName>.*?)\"",\s+\""{(?<projectGuid>.*?)}\""(?<content>.*?)\bEndProject\b", RegexOptions.Singleline | RegexOptions.ExplicitCapture);
|
||||
private static readonly Regex PropertiesDeclaration = new Regex(@"GlobalSection\((?<name>[\w]+Properties)\)\s+=\s+(?<type>(?:post|pre)Solution)(?<entries>.*?)EndGlobalSection", RegexOptions.Singleline | RegexOptions.ExplicitCapture);
|
||||
private static readonly Regex PropertiesEntryDeclaration = new Regex(@"^\s*(?<key>.*?)=(?<value>.*?)$", RegexOptions.Multiline | RegexOptions.ExplicitCapture);
|
||||
|
||||
public static Solution ParseSolutionFile(string filename)
|
||||
{
|
||||
return ParseSolutionContent(File.ReadAllText(filename));
|
||||
}
|
||||
|
||||
public static Solution ParseSolutionContent(string content)
|
||||
{
|
||||
return new Solution
|
||||
{
|
||||
Projects = ParseSolutionProjects(content),
|
||||
Properties = ParseSolutionProperties(content)
|
||||
};
|
||||
}
|
||||
|
||||
private static SolutionProjectEntry[] ParseSolutionProjects(string content)
|
||||
{
|
||||
var projects = new List<SolutionProjectEntry>();
|
||||
var mc = ProjectDeclaration.Matches(content);
|
||||
|
||||
foreach (Match match in mc)
|
||||
{
|
||||
projects.Add(new SolutionProjectEntry
|
||||
{
|
||||
ProjectFactoryGuid = match.Groups["projectFactoryGuid"].Value,
|
||||
Name = match.Groups["name"].Value,
|
||||
FileName = match.Groups["fileName"].Value,
|
||||
ProjectGuid = match.Groups["projectGuid"].Value,
|
||||
});
|
||||
}
|
||||
|
||||
return projects.ToArray();
|
||||
}
|
||||
|
||||
private static SolutionProperties[] ParseSolutionProperties(string content)
|
||||
{
|
||||
var properties = new List<SolutionProperties>();
|
||||
var mc = PropertiesDeclaration.Matches(content);
|
||||
|
||||
foreach (Match match in mc)
|
||||
{
|
||||
var sp = new SolutionProperties
|
||||
{
|
||||
Entries = new List<KeyValuePair<string, string>>(),
|
||||
Name = match.Groups["name"].Value,
|
||||
Type = match.Groups["type"].Value
|
||||
};
|
||||
|
||||
var entries = match.Groups["entries"].Value;
|
||||
var mec = PropertiesEntryDeclaration.Matches(entries);
|
||||
foreach (Match entry in mec)
|
||||
{
|
||||
var key = entry.Groups["key"].Value.Trim();
|
||||
var value = entry.Groups["value"].Value.Trim();
|
||||
sp.Entries.Add(new KeyValuePair<string, string>(key, value));
|
||||
}
|
||||
|
||||
properties.Add(sp);
|
||||
}
|
||||
|
||||
return properties.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user