5 Commits
2.3.2 ... 2.3.3

Author SHA1 Message Date
Tyrrrz
9c715f458e Update version 2023-04-28 17:10:37 +03:00
Tyrrrz
90d93a57ee Remove package readme 2023-04-28 17:09:35 +03:00
Tyrrrz
8da4a61eb7 Fix warnings in local build 2023-04-28 17:07:37 +03:00
Tyrrrz
f718370642 Update NuGet packages 2023-04-28 17:03:30 +03:00
Tyrrrz
83c7af72bf Downgrade target Roslyn version in analyzers
Closes #135
2023-04-28 17:02:50 +03:00
17 changed files with 36 additions and 22 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## v2.3.3 (28-Apr-2023)
- Fixed an issue where the analyzers failed to load in some projects, due to targeting a Roslyn version that was too high.
## v2.3.2 (06-Apr-2023)
- Added name-based ordering to subcommands when displayed in the help text. (Thanks [@CartBlanche](https://github.com/CartBlanche))

View File

@@ -10,8 +10,8 @@
<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net70" Version="1.4.1" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" PrivateAssets="all" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.2" PrivateAssets="all" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />

View File

@@ -17,9 +17,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.1.0" PrivateAssets="all" />
<!-- Make sure to target the lowest possible version of the compiler for wider support -->
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.0.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.2.0" PrivateAssets="all" />
</ItemGroup>
</Project>

View File

@@ -24,7 +24,7 @@ public class OptionMustBeRequiredIfPropertyRequiredAnalyzer : AnalyzerBase
if (property.ContainingType is null)
return;
if (!property.IsRequired)
if (!property.IsRequired())
return;
var option = CommandOptionSymbol.TryResolve(property);

View File

@@ -39,7 +39,7 @@ public class OptionMustHaveUniqueNameAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -38,7 +38,7 @@ public class OptionMustHaveUniqueShortNameAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -37,7 +37,7 @@ public class ParameterMustBeLastIfNonRequiredAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -37,7 +37,7 @@ public class ParameterMustBeLastIfNonScalarAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -24,7 +24,7 @@ public class ParameterMustBeRequiredIfPropertyRequiredAnalyzer : AnalyzerBase
if (property.ContainingType is null)
return;
if (!property.IsRequired)
if (!property.IsRequired())
return;
var parameter = CommandParameterSymbol.TryResolve(property);

View File

@@ -37,7 +37,7 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -37,7 +37,7 @@ public class ParameterMustBeSingleIfNonScalarAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -39,7 +39,7 @@ public class ParameterMustHaveUniqueNameAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -35,7 +35,7 @@ public class ParameterMustHaveUniqueOrderAnalyzer : AnalyzerBase
.ContainingType
.GetMembers()
.OfType<IPropertySymbol>()
.Where(m => !m.Equals(property, SymbolEqualityComparer.Default))
.Where(m => !m.Equals(property))
.ToArray();
foreach (var otherProperty in otherProperties)

View File

@@ -34,6 +34,17 @@ internal static class RoslynExtensions
.FirstOrDefault(i => i.ConstructedFrom.SpecialType == SpecialType.System_Collections_Generic_IEnumerable_T)?
.TypeArguments[0];
// Detect if the property is required through roundabout means so as to not have to take dependency
// on higher versions of the C# compiler.
public static bool IsRequired(this IPropertySymbol property) => property
// Can't rely on the RequiredMemberAttribute because it's generated by the compiler, not added by the user,
// so we have to check for the presence of the `required` modifier in the syntax tree instead.
.DeclaringSyntaxReferences
.Select(r => r.GetSyntax())
.OfType<PropertyDeclarationSyntax>()
.SelectMany(p => p.Modifiers)
.Any(m => m.IsKind((SyntaxKind)8447));
public static bool IsAssignable(this Compilation compilation, ITypeSymbol source, ITypeSymbol destination) =>
compilation.ClassifyConversion(source, destination).Exists;

View File

@@ -10,9 +10,9 @@
<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net70" Version="1.4.1" />
<PackageReference Include="CliWrap" Version="3.6.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" PrivateAssets="all" />
<PackageReference Include="CliWrap" Version="3.6.1" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />

View File

@@ -11,7 +11,6 @@
<PackageTags>command line executable interface framework parser arguments cli app application net core</PackageTags>
<PackageProjectUrl>https://github.com/Tyrrrz/CliFx</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/Tyrrrz/CliFx/blob/master/Changelog.md</PackageReleaseNotes>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageIcon>favicon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -21,13 +20,12 @@
</PropertyGroup>
<ItemGroup>
<None Include="../Readme.md" Pack="true" PackagePath="" Visible="false" />
<None Include="../favicon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.2.0" PrivateAssets="all" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
</ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>2.3.2</Version>
<Version>2.3.3</Version>
<Company>Tyrrrz</Company>
<Copyright>Copyright (C) Oleksii Holub</Copyright>
<LangVersion>latest</LangVersion>