Skip to content

Commit

Permalink
Merge pull request #16 from SkylineCommunications/CommonSolutionUsage
Browse files Browse the repository at this point in the history
Common solution usage
  • Loading branch information
janstaelensskyline authored Feb 16, 2024
2 parents 944b199 + 6ef4f17 commit b22754d
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 15 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.csproj]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.cs]
dotnet_sort_system_directives_first = true
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = false
4 changes: 0 additions & 4 deletions Parsers.Automation/Parsers.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Skyline.DataMiner.CICD.Loggers" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Parsers.Common\Parsers.Common.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Parsers.AutomationTests/Parsers.AutomationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
Expand Down
1 change: 1 addition & 0 deletions Parsers.Common/Parsers.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<ItemGroup>
<PackageReference Include="NuGet.Frameworks" Version="6.6.1" />
<PackageReference Include="Skyline.DataMiner.CICD.FileSystem" Version="1.0.2" />
<PackageReference Include="Skyline.DataMiner.CICD.Loggers" Version="1.0.3" />
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions Parsers.Common/VisualStudio/Projects/IProjectParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects
{
internal interface IProjectParser
{
ProjectStyle GetProjectStyle();

string GetAssemblyName();

IEnumerable<Reference> GetReferences();
Expand Down
5 changes: 5 additions & 0 deletions Parsers.Common/VisualStudio/Projects/LegacyStyleParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ internal LegacyStyleParser(XDocument document, string projectDir)
this.projectDir = projectDir;
}

public ProjectStyle GetProjectStyle()
{
return ProjectStyle.Legacy;
}

public string GetAssemblyName()
{
return document
Expand Down
11 changes: 8 additions & 3 deletions Parsers.Common/VisualStudio/Projects/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ private Project()
/// <value>The package references.</value>
public IEnumerable<PackageReference> PackageReferences => _packageReferences;

/// <summary>
/// Gets the style of the project.
/// </summary>
public ProjectStyle ProjectStyle { get; private set; }

/// <summary>
/// Loads the projects with the specified path.
/// </summary>
Expand All @@ -138,7 +143,6 @@ public static Project Load(string path, string projectName)
string projectDir = FileSystem.Path.GetDirectoryName(path);
var xmlContent = FileSystem.File.ReadAllText(path, Encoding.UTF8);
var document = XDocument.Parse(xmlContent);
// var document = XDocument.Load(path);

IProjectParser parser = ProjectParserFactory.GetParser(document, projectDir);

Expand All @@ -148,11 +152,12 @@ public static Project Load(string path, string projectName)
{
name = assemblyName;
}

var project = new Project
{
AssemblyName = name,
Path = path
Path = path,
ProjectStyle = parser.GetProjectStyle(),
};

project._references.AddRange(parser.GetReferences());
Expand Down
23 changes: 23 additions & 0 deletions Parsers.Common/VisualStudio/Projects/ProjectStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects
{
/// <summary>
/// Style of the project.
/// </summary>
public enum ProjectStyle
{
/// <summary>
/// Unable to verify the style.
/// </summary>
Unknown = -1,

/// <summary>
/// Legacy style.
/// </summary>
Legacy,

/// <summary>
/// SDK style.
/// </summary>
Sdk,
}
}
5 changes: 5 additions & 0 deletions Parsers.Common/VisualStudio/Projects/SdkStyleParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ internal SdkStyleParser(XDocument document, string projectDir)
this.projectDir = projectDir;
}

public ProjectStyle GetProjectStyle()
{
return ProjectStyle.Sdk;
}

public string GetAssemblyName()
{
// Note: by default this element is not present. If not present it is the same as the MSBuild project name (handled in higher level).
Expand Down
21 changes: 21 additions & 0 deletions Parsers.Common/VisualStudio/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Skyline.DataMiner.CICD.Parsers.Common.VisualStudio
using System.Linq;

using Skyline.DataMiner.CICD.FileSystem;
using Skyline.DataMiner.CICD.Loggers;
using Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects;
using Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.SolutionParser;

Expand Down Expand Up @@ -66,6 +67,26 @@ protected Solution(string path)
/// <value>The projects.</value>
public IEnumerable<ProjectInSolution> Projects => SolutionItems.Values.OfType<ProjectInSolution>();

/// <summary>
/// Loads the specified solution path.
/// </summary>
/// <param name="solutionPath">The solution path.</param>
/// <param name="logCollector">The log collector.</param>
/// <returns>Parsed solution.</returns>
/// <exception cref="ArgumentException">Value cannot be null or whitespace. - solutionPath</exception>
/// <exception cref="FileNotFoundException">The specified solution file does not exist.</exception>
public static Solution Load(string solutionPath, ILogCollector logCollector = null)
{
if (String.IsNullOrWhiteSpace(solutionPath))
{
throw new ArgumentException("Value cannot be null or whitespace.", nameof(solutionPath));
}

logCollector?.ReportDebug($"Creating solution from '{solutionPath}'.");

return new Solution(solutionPath);
}

/// <summary>
/// Loads the a project of the solution.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Parsers.CommonTests/Parsers.CommonTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
Expand All @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
Expand Down
4 changes: 0 additions & 4 deletions Parsers.Protocol/Parsers.Protocol.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Skyline.DataMiner.CICD.Loggers" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Parsers.Common\Parsers.Common.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Parsers.ProtocolTests/Parsers.ProtocolTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
Expand Down

0 comments on commit b22754d

Please sign in to comment.