Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ODS-6227] Migrate SdkGen to target .NET 8 (5.x) #1096

Merged
merged 6 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override bool BuildProperty(object obj, PropertyInfo propertyInfo)
.GetValue(lookup).ToString();

var uri = lookup.GetType()
.GetProperty(EdFiConstants.Namespace)
.GetProperty($"Var{EdFiConstants.Namespace}")
.GetValue(lookup);

var descriptorValue = uri != null && !string.IsNullOrEmpty(uri.ToString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override bool BuildProperty(object obj, PropertyInfo propertyInfo)
{
var typeName = obj.GetType().Name;

if (propertyInfo.PropertyType != typeof(string) || propertyInfo.Name != EdFiConstants.Namespace)
if (propertyInfo.PropertyType != typeof(string) || propertyInfo.Name != $"Var{EdFiConstants.Namespace}")
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</metadata>
<files>
<file src="readme.txt" target="" />
<file src="csharp\src\EdFi.OdsApi.Sdk\bin\$configuration$\net6.0\EdFi.OdsApi.Sdk.dll" target="lib\net6.0" />
<file src="csharp\src\EdFi.OdsApi.Sdk\bin\$configuration$\net8.0\EdFi.OdsApi.Sdk.dll" target="lib\net6.0" />
</files>
</package>
28 changes: 14 additions & 14 deletions Utilities/SdkGen/EdFi.SdkGen.Console/EdFi.SdkGen.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFramework>net8.0</TargetFramework>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Remove="csharp\**" />
<EmbeddedResource Remove="csharp\**" />
<None Remove="csharp\**" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Remove="csharp\**" />
<EmbeddedResource Remove="csharp\**" />
<None Remove="csharp\**" />
</ItemGroup>
<ItemGroup>
<None Remove="readme.txt" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Content Include="readme.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="log4net" Version="2.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<None Update="EdFi.OdsApi.Sdk.nuspec">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class OpenApiCodeGenCliRunner
private const string Profiles = "Profiles";
private const string Composites = "Composites";
private const string Identity = "Identity";
private const string Java = "java";
private const string All = "All";
private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly Options _options;
Expand Down Expand Up @@ -68,15 +67,15 @@ private void RunCliCodegen(IEnumerable<OpenApiDetail> apiEndpoints)
// code-gen paramaters
string[] @params =
{
$"-Xms3g -jar {_options.CliExecutableFullName()}", "generate", "-g csharp-netcore", $"-i {apiEndpoint.EndpointUri}",
$"-Xms3g -jar {_options.CliExecutableFullName()}", "generate", "-g csharp", $"-i {apiEndpoint.EndpointUri}",
$"--api-package {apiPackage}", $"--model-package {modelPackage}", $"-o {_options.OutputFolder}",
$"--additional-properties packageName={_options.Namespace},targetFramework=net6.0,netCoreProjectFile=true",
$"--additional-properties packageName={_options.Namespace},targetFramework=net8.0,netCoreProjectFile=true",
"--global-property modelTests=false --global-property apiTests=false --global-property apiDocs=false --global-property modelDocs=false --skip-validate-spec"
};

_log.Info($"Generating C# SDK for {apiEndpoint.EndpointUri}");

ShellProcess(Java, @params);
ShellProcess(_options.JavaPath, @params);
}
}

Expand Down
9 changes: 8 additions & 1 deletion Utilities/SdkGen/EdFi.SdkGen.Console/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class Options
[Option(
'v',
"cliVersion",
Default = "6.6.0",
Default = "7.2.0",
HelpText = "the version of openapi-codegen-cli to download")]
public string CliVersion { get; set; }

Expand Down Expand Up @@ -74,6 +74,13 @@ public sealed class Options
HelpText = "include identity in the generation of the assembly")]
public bool IncludeIdentity { get; set; }

[Option(
'j',
"java-path",
Default = "java",
HelpText = "the path to the java executable")]
public string JavaPath { get; set; }

[Option(
'k',
"core-only",
Expand Down
Loading