Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
fail-fast: false
matrix:
configuration: [CSharp, VisualBasic]
project: [Analyzers, CodeFixers, Extensions, HighPerformance, SourceGenerators, DynamicCast, Swagger]
project: [Analyzers, CodeFixers, Extensions, HighPerformance, SourceGenerators, DynamicCast, Kiota]
exclude:
- configuration: VisualBasic
project: DynamicCast
- configuration: VisualBasic
project: Swagger
project: Kiota

env:
PROJECT: ${{ matrix.project }}
Expand Down
4 changes: 2 additions & 2 deletions CompilerPlatform.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<BuildType Project="CSharp" />
<Build Solution="VisualBasic|*" Project="false" />
</Project>
<Project Path="src/features/Riverside.CompilerPlatform.Features.Swagger/Riverside.CompilerPlatform.Features.Swagger.csproj" Id="ba9bb2cd-6a93-4e05-9e46-4917360831a2">
<Project Path="src/features/Riverside.CompilerPlatform.Features.Kiota/Riverside.CompilerPlatform.Features.Kiota.csproj">
<BuildType Project="CSharp" />
<Build Solution="VisualBasic|*" Project="false" />
</Project>
Expand All @@ -26,7 +26,7 @@
<BuildType Project="CSharp" />
<Build Solution="VisualBasic|*" Project="false" />
</Project>
<Project Path="tests/Riverside.CompilerPlatform.Features.Tests/Riverside.CompilerPlatform.Features.Tests.csproj" Id="198c5333-faf0-4f00-b4ed-f714bb5309c9" />
<Project Path="tests/Riverside.CompilerPlatform.Features.Tests/Riverside.CompilerPlatform.Features.Tests.csproj" />
<Project Path="tests/Riverside.CompilerPlatform.VisualBasic.Tests/Riverside.CompilerPlatform.VisualBasic.Tests.vbproj">
<BuildType Project="VisualBasic" />
<Build Solution="CSharp|*" Project="false" />
Expand Down
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project>

<Import Project="$(MSBuildThisFileDirectory)\eng\PackageMetadata.props" Condition="!$(MSBuildProjectName.Contains('Tests'))" />
<Import Project="$(MSBuildThisFileDirectory)\eng\CurrentVersion.props" />

<PropertyGroup>
<RootDirectory>$(MSBuildThisFileDirectory)</RootDirectory>
<SourceDirectory>$(RootDirectory)src</SourceDirectory>
Expand Down Expand Up @@ -30,4 +32,5 @@
<ItemGroup>
<Compile Condition="'$(Language)' == 'C#' and '$(IsLangMT)' == 'true'" Include="$(ExtensionsDirectory)\GlobalUsings.cs" />
</ItemGroup>

</Project>
67 changes: 67 additions & 0 deletions src/features/Riverside.CompilerPlatform.Features.Kiota/Kiota.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<Project>

<PropertyGroup>
<Kiota_MinLangVersion>7.3</Kiota_MinLangVersion>
<Kiota_AuthPackageVersion>1.21.2</Kiota_AuthPackageVersion>
<Kiota_BundlePackageVersion>1.21.2</Kiota_BundlePackageVersion>
</PropertyGroup>

<!--<Target Name="Kiota_EnsureDependencies" BeforeTargets="CollectPackageReferences">
<ItemGroup>
<PackageReference
Include="Microsoft.Kiota.Authentication.Azure"
Version="$(Kiota_AuthPackageVersion)"
Condition="'@(PackageReference->WithMetadataValue('Identity', 'Microsoft.Kiota.Authentication.Azure'))' == ''" />
<PackageReference
Include="Microsoft.Kiota.Bundle"
Version="$(Kiota_BundlePackageVersion)"
Condition="'@(PackageReference->WithMetadataValue('Identity', 'Microsoft.Kiota.Bundle'))' == ''" />
</ItemGroup>
</Target>-->

<Target Name="Kiota_ValidateLanguageAndFramework" BeforeTargets="CoreCompile">
<ItemGroup>
<_Kiota_TargetFramework Include="$(TargetFramework)" Condition="'$(TargetFramework)' != ''" />
<_Kiota_TargetFramework Include="$(TargetFrameworks)" Condition="'$(TargetFrameworks)' != ''" />
<_Kiota_InvalidFramework Include="@(_Kiota_TargetFramework)"
Condition="!$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', '^netstandard2\.(0|1)$|^net462$|^net([8-9]|[1-9][0-9])(?:\.[0-9]+)?(?:[-.].*)?$'))" />
</ItemGroup>

<Error
Condition="'$(LangVersion)' == ''"
Code="KG1001"
Text="Riverside Kiota requires C# LangVersion 7.3 or later. Set &lt;LangVersion&gt;7.3&lt;/LangVersion&gt; or newer." />

<Error
Condition="
'$(LangVersion)' != ''
and !($([System.String]::Copy('$(LangVersion)').Equals('latest', System.StringComparison.OrdinalIgnoreCase)))
and !($([System.String]::Copy('$(LangVersion)').Equals('latestmajor', System.StringComparison.OrdinalIgnoreCase)))
and !($([System.String]::Copy('$(LangVersion)').Equals('preview', System.StringComparison.OrdinalIgnoreCase)))
and $([System.Text.RegularExpressions.Regex]::IsMatch('$(LangVersion)', '^[0-9]+(\.[0-9]+)?$'))
and !$([MSBuild]::VersionGreaterThanOrEquals('$(LangVersion)', '$(Kiota_MinLangVersion)'))"
Code="KG1002"
Text="The Advanced Compiler Services for .NET library requires C# 7.3 or later. The current language version is '$(LangVersion)'." />

<Error
Condition="
'$(LangVersion)' != ''
and !($([System.String]::Copy('$(LangVersion)').Equals('latest', System.StringComparison.OrdinalIgnoreCase)))
and !($([System.String]::Copy('$(LangVersion)').Equals('latestmajor', System.StringComparison.OrdinalIgnoreCase)))
and !($([System.String]::Copy('$(LangVersion)').Equals('preview', System.StringComparison.OrdinalIgnoreCase)))
and !$([System.Text.RegularExpressions.Regex]::IsMatch('$(LangVersion)', '^[0-9]+(\.[0-9]+)?$'))"
Code="KG1003"
Text="The Advanced Compiler Services for .NET library requires C# 7.3 or later. Unsupported LangVersion value '$(LangVersion)'." />

<Error
Condition="'@(_Kiota_InvalidFramework)' != ''"
Code="KG1004"
Text="The Advanced Compiler Services for .NET library supports only netstandard2.0, netstandard2.1, net462, and net8.0 or later. Invalid target framework(s): @(_Kiota_InvalidFramework, ', ')." />

<Warning
Condition="'$(Nullable)' == '' or $([System.String]::Copy('$(Nullable)').Equals('disable', System.StringComparison.OrdinalIgnoreCase))"
Code="KG2001"
Text="Nullable is disabled. Consider enabling nullable reference types (&lt;Nullable&gt;enable&lt;/Nullable&gt;) for generated Kiota clients." />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace Riverside.CompilerPlatform.Features.Swagger;
namespace Riverside.CompilerPlatform.Features.Kiota;

partial class KiotaEngine
{
public enum Accessibility

Check warning on line 5 in src/features/Riverside.CompilerPlatform.Features.Kiota/KiotaEngine.Enums.cs

View workflow job for this annotation

GitHub Actions / build (CSharp, Kiota)

Missing XML comment for publicly visible type or member 'KiotaEngine.Accessibility'

Check warning on line 5 in src/features/Riverside.CompilerPlatform.Features.Kiota/KiotaEngine.Enums.cs

View workflow job for this annotation

GitHub Actions / build (CSharp, Kiota)

Missing XML comment for publicly visible type or member 'KiotaEngine.Accessibility'
{
Internal,

Check warning on line 7 in src/features/Riverside.CompilerPlatform.Features.Kiota/KiotaEngine.Enums.cs

View workflow job for this annotation

GitHub Actions / build (CSharp, Kiota)

Missing XML comment for publicly visible type or member 'KiotaEngine.Accessibility.Internal'

Check warning on line 7 in src/features/Riverside.CompilerPlatform.Features.Kiota/KiotaEngine.Enums.cs

View workflow job for this annotation

GitHub Actions / build (CSharp, Kiota)

Missing XML comment for publicly visible type or member 'KiotaEngine.Accessibility.Internal'
Private,

Check warning on line 8 in src/features/Riverside.CompilerPlatform.Features.Kiota/KiotaEngine.Enums.cs

View workflow job for this annotation

GitHub Actions / build (CSharp, Kiota)

Missing XML comment for publicly visible type or member 'KiotaEngine.Accessibility.Private'

Check warning on line 8 in src/features/Riverside.CompilerPlatform.Features.Kiota/KiotaEngine.Enums.cs

View workflow job for this annotation

GitHub Actions / build (CSharp, Kiota)

Missing XML comment for publicly visible type or member 'KiotaEngine.Accessibility.Private'
Protected,
Public,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text;
using Riverside.CompilerPlatform.Helpers;
using System.Text;

namespace Riverside.CompilerPlatform.Features.Swagger;
namespace Riverside.CompilerPlatform.Features.Kiota;

partial class KiotaEngine
{
Expand All @@ -13,19 +14,19 @@ partial class KiotaEngine
/// </returns>
public override string ToString()
{
var command = new StringBuilder().Append("kiota generate");
var command = new StringBuilder().Append("generate");

if (!string.IsNullOrWhiteSpace(Path))
{
command.Append($" --openapi {Path}");
command.Append($" --openapi {SanitizationHelpers.EscapeArg(Path!)}");
}
if (!string.IsNullOrWhiteSpace(Manifest))
{
command.Append($" --manifest {Manifest}");
command.Append($" --manifest {SanitizationHelpers.EscapeArg(Manifest!)}");
}
if (!string.IsNullOrWhiteSpace(Output))
{
command.Append($" --output {Output}");
command.Append($" --output {SanitizationHelpers.EscapeArg(Output!)}");
}
command.Append($" --language {Language}");
if (!string.IsNullOrWhiteSpace(ClassName))
Expand Down Expand Up @@ -56,68 +57,68 @@ public override string ToString()
{
command.Append($" --additional-data {AdditionalData}");
}
if (Serializer is not null)
if (Serializer is not null && Serializer.Length > 0)
{
var serializers = new StringBuilder().Append(" --serializer ");
foreach (var serializer in Serializer)
{
serializers.Append(serializer + "|");
}
serializers.Remove(serializers.Length, 1); // remove final '|' char
serializers.Remove(serializers.Length - 1, 1); // remove final '|' char
command.Append(serializers.ToString());
}
if (Deserializer is not null)
if (Deserializer is not null && Deserializer.Length > 0)
{
var deserializers = new StringBuilder().Append(" --deserializer ");
foreach (var deserializer in Deserializer)
{
deserializers.Append(deserializer + "|");
}
deserializers.Remove(deserializers.Length, 1); // remove final '|' char
deserializers.Remove(deserializers.Length - 1, 1); // remove final '|' char
command.Append(deserializers.ToString());
}
if (CleanOutput is not null)
{
command.Append($" --clean-output {CleanOutput}");
}
if (StructuredMimeTypes is not null)
if (StructuredMimeTypes is not null && StructuredMimeTypes.Length > 0)
{
var structuredMimeTypes = new StringBuilder().Append(" --structured-mime-types ");
foreach (var structuredMimeType in StructuredMimeTypes)
{
structuredMimeTypes.Append(structuredMimeType + "|");
}
structuredMimeTypes.Remove(structuredMimeTypes.Length, 1); // remove final '|' char
structuredMimeTypes.Remove(structuredMimeTypes.Length - 1, 1); // remove final '|' char
command.Append(structuredMimeTypes.ToString());
}
if (IncludePath is not null)
if (IncludePath is not null && IncludePath.Length > 0)
{
var includePaths = new StringBuilder().Append(" --include-path ");
foreach (var includePath in IncludePath)
{
includePaths.Append(includePath + "|");
}
includePaths.Remove(includePaths.Length, 1); // remove final '|' char
includePaths.Remove(includePaths.Length - 1, 1); // remove final '|' char
command.Append(includePaths.ToString());
}
if (ExcludePath is not null)
if (ExcludePath is not null && ExcludePath.Length > 0)
{
var excludePaths = new StringBuilder().Append(" --exclude-path ");
foreach (var excludePath in ExcludePath)
{
excludePaths.Append(excludePath + "|");
}
excludePaths.Remove(excludePaths.Length, 1); // remove final '|' char
excludePaths.Remove(excludePaths.Length - 1, 1); // remove final '|' char
command.Append(excludePaths.ToString());
}
if (DisableValidationRules is not null)
if (DisableValidationRules is not null && DisableValidationRules.Length > 0)
{
var disableValidationRules = new StringBuilder().Append(" --disable-validation-rules ");
foreach (var disableValidationRule in DisableValidationRules)
{
disableValidationRules.Append(disableValidationRule + "|");
}
disableValidationRules.Remove(disableValidationRules.Length, 1); // remove final '|' char
disableValidationRules.Remove(disableValidationRules.Length - 1, 1); // remove final '|' char
command.Append(disableValidationRules.ToString());
}
if (ClearCache is not null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;
using System.Diagnostics.CodeAnalysis;

namespace Riverside.CompilerPlatform.Features.Swagger;
namespace Riverside.CompilerPlatform.Features.Kiota;

/// <summary>
/// Represents the configuration and options for generating code using the Kiota engine.
Expand Down Expand Up @@ -128,6 +128,7 @@ public partial class KiotaEngine
/// <param name="l">The target programming language for code generation.</param>
/// <param name="c">The name of the root class to be generated. Can be null to use a default class name.</param>
/// <param name="tam">The access modifier to apply to generated types. Can be null to use the default accessibility.</param>
/// <param name="n">The namespace for the generated client class. Can be null to use the default namespace.</param>
/// <param name="ll">The log level to use for diagnostic output during generation. Can be null to use the default log level.</param>
/// <param name="b">Indicates whether to use a backing store for generated models. If null, the default behavior is used.</param>
/// <param name="ebc">Indicates whether to exclude backward compatible code from the output. If null, the default behavior is used.</param>
Expand All @@ -141,14 +142,16 @@ public partial class KiotaEngine
/// <param name="dvr">An array of validation rules to disable during generation. Can be null to enable all rules.</param>
/// <param name="cc">Indicates whether to clear the internal cache before generation. If null, the default behavior is used.</param>
/// <param name="dsv">Indicates whether to disable SSL validation for network operations. If null, the default behavior is used.</param>
public KiotaEngine(string? d, string? a, string? o, GenerationLanguage l, string? c, Accessibility? tam, ConsoleLogLevel? ll, bool? b, bool? ebc, bool? ad, string[]? s, string[]? ds, bool? co, string[]? m, string[]? i, string[]? e, ValidationRules[]? dvr, bool? cc, bool? dsv)
[SetsRequiredMembers]
public KiotaEngine(string? d, string? a, string? o, GenerationLanguage l, string? c, Accessibility? tam, string? n, ConsoleLogLevel? ll, bool? b, bool? ebc, bool? ad, string[]? s, string[]? ds, bool? co, string[]? m, string[]? i, string[]? e, ValidationRules[]? dvr, bool? cc, bool? dsv)
{
Path = d;
Manifest = a;
Output = o;
Language = l;
ClassName = c;
TypeAccessModifier = tam;
NamespaceName = n;
LogLevel = ll;
BackingStore = b;
ExcludeBackwardCompatible = ebc;
Expand Down
Loading
Loading