Skip to content

Commit 7d81f44

Browse files
committed
Tool: CLI Support for TargetFramework and RuntimeIdentifier
Both: Support for PackagesProviderIconContentMaxSize Option
1 parent 039b88d commit 7d81f44

34 files changed

Lines changed: 421 additions & 76 deletions

PackScan.sln

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
ProjectSection(SolutionItems) = preProject
1313
.editorconfig = .editorconfig
1414
.gitignore = .gitignore
15+
build.ps1 = build.ps1
1516
Directory.Build.props = Directory.Build.props
1617
global.json = global.json
1718
LICENSE = LICENSE
1819
nuget.config = nuget.config
19-
pack.ps1 = pack.ps1
2020
ReadMe.md = ReadMe.md
2121
EndProjectSection
2222
EndProject
23-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{C20C1112-EF7A-48C1-9282-872163BBDFC4}"
24-
ProjectSection(SolutionItems) = preProject
25-
.config\dotnet-tools.json = .config\dotnet-tools.json
26-
EndProjectSection
27-
EndProject
2823
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B4BAADD5-BEF6-4D5B-9CB6-48C85D7D5D06}"
2924
EndProject
3025
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PackScan.Tool", "src\PackScan.Tool\PackScan.Tool.csproj", "{26685B24-B2D0-4C68-AE5F-230F9424DBF5}"
@@ -84,7 +79,6 @@ Global
8479
HideSolutionNode = FALSE
8580
EndGlobalSection
8681
GlobalSection(NestedProjects) = preSolution
87-
{C20C1112-EF7A-48C1-9282-872163BBDFC4} = {40512514-8795-4C6A-A58F-6AFC87C17B2F}
8882
{26685B24-B2D0-4C68-AE5F-230F9424DBF5} = {1EF8F5B9-DD77-4162-A819-85A2B49FED7B}
8983
{6A110BE4-B6E9-48A6-BFEB-1E3F2E90B84D} = {F9F7EE5C-DD30-439B-ABB0-33947D2C833B}
9084
{9E8281F2-EC4E-404E-8D3C-72759FEC6D62} = {1EF8F5B9-DD77-4162-A819-85A2B49FED7B}
@@ -99,6 +93,8 @@ Global
9993
SolutionGuid = {BB925338-FA98-438B-919B-EB37667CC9A9}
10094
EndGlobalSection
10195
GlobalSection(SharedMSBuildProjectFiles) = preSolution
96+
src\PackScan.Shared\PackScan.Shared.projitems*{19e1358b-9100-4905-ba7b-a38a6c29e723}*SharedItemsImports = 5
97+
src\PackScan.Shared\PackScan.Shared.projitems*{26685b24-b2d0-4c68-ae5f-230f9424dbf5}*SharedItemsImports = 5
10298
src\PackScan.Shared\PackScan.Shared.projitems*{51c5972d-550e-4123-98dd-4ed087e44c5f}*SharedItemsImports = 5
10399
src\PackScan.Shared\PackScan.Shared.projitems*{8f2e4832-2a8e-46cb-98f8-3ece0f45cf3d}*SharedItemsImports = 5
104100
src\PackScan.Shared\PackScan.Shared.projitems*{9e8281f2-ec4e-404e-8d3c-72759fec6d62}*SharedItemsImports = 13

ReadMe.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ Default value: `None`
240240
Determines if and from where the release notes should be loaded. [Here](#content-load-mode), you will find the supported values.</br>
241241
Default value: `None`</br>
242242

243+
- **PackagesProviderIconContentMaxSize**</br>
244+
Specifies the maximum size in "\<width>x\<height>" format to which the icon should be resized.</br>
245+
Default value: `512x512`</br>
246+
243247
### Project Items
244248

245249
- **AllowedLicense**</br>
@@ -291,7 +295,9 @@ Default value: `%temp%/PackScan.PackagesProvider.Writer/DownloadCache`
291295

292296
### CLI Parameters
293297

294-
- **-p, --project-path** | The path to the project folder or project file. Default value: The current working directory
298+
- **-f, --target-framework** | Specifies the target framework for the project. Default value: The current target framework of the project.
299+
- **-ri, --runtime-identifier** | Defines the runtime identifier for the project. Default value: The current runtime identifier of the project.
300+
- **-p, --project-path** | The path to the project folder or project file. Default value: The current working directory.
295301
- **-l, --language** | Sets the programming language to be used. Default value: The language based on the project file extension.
296302
- **--clear-output** | Determines whether the output folder should be emptied before execution (true) or not (false). Default value: `false`
297303
- **-o, --output** | Overrides the project property **PackagesProviderOutputPath**.
@@ -304,6 +310,7 @@ Default value: `%temp%/PackScan.PackagesProvider.Writer/DownloadCache`
304310
- **--add-project-file** | Overrides the project property **PackagesProviderGenerateProjectFile**.
305311
- **--load-mode** | Overwrites the default values of the following load-mode values. [Here](#content-load-mode), you will find the supported values. Default value: \<empty>
306312
- **--icon-load-mode** | Overrides the project property **PackagesProviderIconContentLoadMode**.
313+
- **--icon-max-size** | Specifies the maximum size in "\<width>x\<height>" format to which the icon should be resized.
307314
- **--license-load-mode** | Overrides the project property **PackagesProviderLicenseContentLoadMode**.
308315
- **--readme-load-mode** | Overrides the project property **PackagesProviderReadMeContentLoadMode**.
309316
- **--release-notes-load-mode** | Overrides the project property **PackagesProviderReleaseNotesContentLoadMode**.
@@ -352,6 +359,12 @@ If you would like to contribute code, please fork the repository and create a pu
352359

353360
# ChangeLog
354361

362+
## [v0.3.0 - 2023-11-13](https://github.com/loop8ack/PackScan/releases/tag/v0.3.0)
363+
### Added
364+
- PackScan.Tool parameter to specify the target framework for the project.
365+
- PackScan.Tool parameter to define the runtime identifier for the project.
366+
- Functionality to specify the maximum size for downloaded icons in "<width>x<height>" format.
367+
355368
## [v0.2.1 - 2023-11-06](https://github.com/loop8ack/PackScan/releases/tag/v0.2.1)
356369
### Fixed
357370
- Resolved a bug that caused issues with specific platform versions, such as those used in MAUI projects.

build.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dotnet pack -o artifacts -c Release ./src/PackScan.Analyzer
2+
dotnet pack -o artifacts -c Release ./src/PackScan.Defaults
3+
dotnet pack -o artifacts -c Release ./src/PackScan.Tool
4+
dotnet pack -o artifacts -c Release ./src/PackScan.PackagesProvider.Abstractions

pack.ps1

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/NuGet.Metadata.props

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<PackageOutputPath>../../artifacts</PackageOutputPath>
5-
</PropertyGroup>
6-
7-
<PropertyGroup>
8-
<Version>0.2.1</Version>
4+
<Version>0.3.0</Version>
95
<Authors>Loop8ack</Authors>
106
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
117
<PackageLicenseExpression>MIT</PackageLicenseExpression>

src/PackScan.Analyzer/Core/Diagnostics.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Immutable;
2+
using System.Drawing;
23

34
using Microsoft.CodeAnalysis;
45

@@ -16,6 +17,7 @@ private enum Id
1617
OptionNotParsedEnum,
1718
OptionNoParsedBool,
1819
OptionNoParsedValue,
20+
OptionNoParsedSize,
1921

2022
// Licenses Analyzer
2123
LicenseNotAllowed = 200,
@@ -111,6 +113,23 @@ public static Diagnostic Create(string optionName, string value, string typeName
111113
}
112114
}
113115

116+
public static class OptionNotParsedSize
117+
{
118+
public static DiagnosticDescriptor Descriptor { get; }
119+
= new DiagnosticDescriptor(
120+
id: $"{Prefix}{(int)Id.OptionNoParsedSize:000}",
121+
title: "Not supported value",
122+
messageFormat: "Could not parse '{0}' value '{1}' as size. Supported format: <width>x<height>",
123+
category: Category,
124+
DiagnosticSeverity.Error,
125+
isEnabledByDefault: true);
126+
127+
public static Diagnostic Create(string optionName, string value)
128+
{
129+
return Diagnostic.Create(Descriptor, Location.None, optionName, value);
130+
}
131+
}
132+
114133
public static class LicenseNotAllowed
115134
{
116135
public static DiagnosticDescriptor Descriptor { get; }

src/PackScan.Analyzer/Core/Options/AnalyzerConfigOptionsExtensions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.CodeAnalysis.Diagnostics;
22

3+
using SixLabors.ImageSharp;
4+
35
namespace PackScan.Analyzer.Core.Options;
46

57
internal static class AnalyzerConfigOptionsExtensions
@@ -49,6 +51,21 @@ public static OptionValue<TEnum> GetOptionEnum<TEnum>(this AnalyzerConfigOptions
4951
return new(name, Diagnostics.OptionNotFound.Create(name));
5052
}
5153

54+
public static OptionValue<Size?> GetOptionNullableSKSize(this AnalyzerConfigOptions options, string name)
55+
{
56+
if (options.TryGetValue(Prefix + name, out string? str))
57+
{
58+
if (string.IsNullOrEmpty(str))
59+
return new(name, (Size?)null);
60+
61+
return Utils.TryParseImageSharpSize(str, out Size? value)
62+
? new(name, value)
63+
: new(name, Diagnostics.OptionNotParsedSize.Create(name, str));
64+
}
65+
66+
return new(name, (Size?)null);
67+
}
68+
5269
public static OptionValue<TValue> GetOptionValue<TValue>(this AnalyzerConfigOptions options, string name, string typeName, IReadOnlyDictionary<string, TValue> valueMapping)
5370
{
5471
if (options.TryGetValue(Prefix + name, out string? str))

src/PackScan.Analyzer/Core/Services/PackagesProviderGeneratorService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using PackScan.PackagesProvider.Generator.Info;
1212
using PackScan.PackagesReader.Abstractions;
1313

14+
using SixLabors.ImageSharp;
15+
1416
using CodeGenerator = PackScan.PackagesProvider.Generator.PackagesProviderGenerator;
1517

1618
namespace PackScan.Analyzer.Core.Services;
@@ -27,6 +29,7 @@ internal record class PackagesProviderGeneratorService
2729
private OptionValue<bool> NullableAnnotations { get; set; }
2830
private OptionValue<bool> LoadContentParallel { get; set; }
2931
private OptionValue<ContentLoadMode> IconContentLoadMode { get; set; }
32+
private OptionValue<Size?> IconContentMaxSize { get; set; }
3033
private OptionValue<ContentLoadMode> LicenseContentLoadMode { get; set; }
3134
private OptionValue<ContentLoadMode> ReadMeContentLoadMode { get; set; }
3235
private OptionValue<ContentLoadMode> ReleaseNotesContentLoadMode { get; set; }
@@ -43,6 +46,7 @@ public PackagesProviderGeneratorService(AnalyzerConfigOptions options)
4346
NullableAnnotations = options.GetOptionBool("PackagesProviderNullableAnnotations");
4447
LoadContentParallel = options.GetOptionBool("PackagesProviderLoadContentsParallel");
4548
IconContentLoadMode = options.GetOptionEnum<ContentLoadMode>("PackagesProviderIconContentLoadMode");
49+
IconContentMaxSize = options.GetOptionNullableSKSize("PackagesProviderIconContentMaxSize");
4650
LicenseContentLoadMode = options.GetOptionEnum<ContentLoadMode>("PackagesProviderLicenseContentLoadMode");
4751
ReadMeContentLoadMode = options.GetOptionEnum<ContentLoadMode>("PackagesProviderReadMeContentLoadMode");
4852
ReleaseNotesContentLoadMode = options.GetOptionEnum<ContentLoadMode>("PackagesProviderReleaseNotesContentLoadMode");
@@ -79,6 +83,7 @@ private IReadOnlyList<Diagnostic> ValidateOptions()
7983
NullableAnnotations.Validate(diagnostics);
8084
LoadContentParallel.Validate(diagnostics);
8185
IconContentLoadMode.Validate(diagnostics);
86+
IconContentMaxSize.Validate(diagnostics);
8287
LicenseContentLoadMode.Validate(diagnostics);
8388
ReadMeContentLoadMode.Validate(diagnostics);
8489
ReleaseNotesContentLoadMode.Validate(diagnostics);
@@ -101,6 +106,7 @@ private void CoreGenerate(SourceProductionContext context)
101106
GenerateProjectFile = false,
102107
ContentWriteMode = ContentWriteMode.InCode,
103108
IconContentLoadMode = IconContentLoadMode,
109+
IconContentMaxSize = IconContentMaxSize,
104110
LicenseContentLoadMode = LicenseContentLoadMode,
105111
ReadMeContentLoadMode = ReadMeContentLoadMode,
106112
ReleaseNotesContentLoadMode = ReleaseNotesContentLoadMode,

src/PackScan.Analyzer/PackScan.Analyzer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<Import Project="..\PackScan.Shared\PackScan.Shared.projitems" Label="Shared" />
4+
35
<Import Project="../NuGet.Metadata.props" />
46

57
<PropertyGroup>
@@ -9,6 +11,7 @@
911
<DevelopmentDependency>true</DevelopmentDependency>
1012
<IsRoslynComponent>true</IsRoslynComponent>
1113
<NoWarn>$(NoWarn);NU5128</NoWarn>
14+
<DefineConstants>$(DefineConstants);PackScan_Analyzer</DefineConstants>
1215
</PropertyGroup>
1316

1417
<ItemGroup>

src/PackScan.Analyzer/PackScan.Analyzer.targets

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
<Import Project="$(MSBuildThisFileDirectory)\PackScan.Defaults.targets"
44
Condition="Exists('$(MSBuildThisFileDirectory)\PackScan.Defaults.targets')"/>
5-
5+
66
<ItemGroup>
7-
7+
88
<!-- Core -->
99
<CompilerVisibleProperty Include="Language" />
1010
<CompilerVisibleProperty Include="TargetFramework" />
1111
<CompilerVisibleProperty Include="RuntimeIdentifier" />
1212
<CompilerVisibleProperty Include="MSBuildProjectDirectory" />
1313
<CompilerVisibleProperty Include="BaseIntermediateOutputPath" />
14-
14+
1515
<!-- Reader -->
1616
<CompilerVisibleProperty Include="_KnownPackageIds" />
1717

@@ -36,7 +36,8 @@
3636
<CompilerVisibleProperty Include="PackagesProviderReleaseNotesContentLoadMode" />
3737
<CompilerVisibleProperty Include="PackagesProviderDownloadCacheFolder" />
3838
<CompilerVisibleProperty Include="PackagesProviderWorkingDirectory" />
39+
<CompilerVisibleProperty Include="PackagesProviderIconContentMaxSize" />
3940

4041
</ItemGroup>
41-
42+
4243
</Project>

0 commit comments

Comments
 (0)