Skip to content

Conversation

@jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Mar 20, 2025

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec
Copy link
Collaborator Author

jmarrec commented Mar 20, 2025

Launching a C# workflow on this branch: https://github.com/NREL/OpenStudio/actions/runs/13973672884

@jmarrec
Copy link
Collaborator Author

jmarrec commented Mar 20, 2025

My change is good, that error is gone, but C# bindings are still broken

All projects are up-to-date for restore.
/media/DataExt4/Software/Others/OS-build-csharp2/csharp_wrapper/generated_sources/OpenStudioModelResources/OpenStudioModelResources.cs(29,76): error CS1503: Argument 1: cannot convert from 'OpenStudio.EnergyManagementSystemCurveOrTableIndexVariable' to 'OpenStudio.Model' [/media/DataExt4/Software/Others/OS-build-csharp2/csharp_wrapper/OpenStudio.csproj]

@jmarrec
Copy link
Collaborator Author

jmarrec commented Mar 20, 2025

It got beef with

// Overloaded Ctor, calling Ctor that doesn't use Curve
public EnergyManagementSystemCurveOrTableIndexVariable(Model model, OpenStudio.Curve curve)
: this(model) {
this.setCurveOrTableObject(curve);
}

Not sure what's up, will try to get to it tomorrow

@jmarrec jmarrec closed this Mar 20, 2025
@jmarrec jmarrec reopened this Mar 20, 2025
@jmarrec
Copy link
Collaborator Author

jmarrec commented Mar 20, 2025

(hit the wrong button sorry)

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

Oh ok, actually the issue is not where I thought it was, it's here:

public OptionalPythonPluginSearchPaths pythonPluginSearchPaths() {
return OpenStudio.OpenStudioModelResources.pythonPluginSearchPaths(this);
}

This happened when wrapping PythonPluginSearchPaths. It got added it the wrong location

fe3461a#diff-b21ac9f937ee3830c707b3af186bb6ba53cc7a0b43fd114df09b071ed471adf7R343

@jmarrec jmarrec changed the title Hotfix C# bindings for #5365 Hotfix C# bindings for #5365 and #5312 Apr 2, 2025
@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

Alright, locally it builds fine. Launching a C# CI run at https://github.com/NREL/OpenStudio/actions/runs/14214305608

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

Alright, working on CI. We have new missing partial classes though, I guess it's time to fix it.

Remember https://github.com/NREL/OpenStudio/blob/a882f64d0989414b26e18dc071415740ee92c43c/developer/ruby/FindMissingSWIGTypes.rb ?

@jmarrec jmarrec added the Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. label Apr 2, 2025
Not sure why it was excluded entirely, maybe just a typo? @TShapinsky FYI

Last one standing is std::string_view, cf #5393
@jmarrec jmarrec changed the title Hotfix C# bindings for #5365 and #5312 Fix C# bindings - unbreak the build and add missing partial classes Apr 2, 2025
%}

%ignore openstudio::alfalfa::AlfalfaComponentBase;
%ignore openstudio::alfalfa::AlfalfaComponentBase::clone;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TShapinsky not sure why it was entirely ignored, or if it was just a typo?

Not ignoring it doesn't mean you can instantiate it.

In [2]: openstudio.alfalfa.AlfalfaComponentBase()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 openstudio.alfalfa.AlfalfaComponentBase()

File /media/DataExt4/Software/Others/OS-build-release2/Products/python/openstudioalfalfa.py:141, in AlfalfaComponentBase.__init__(self, *args, **kwargs)
    140 def __init__(self, *args, **kwargs):
--> 141     raise AttributeError("No constructor defined - class is abstract")

AttributeError: No constructor defined - class is abstract

Comment on lines +97 to +105
#if defined(SWIGCSHARP) || defined(SWIGJAVA)
%inline {
namespace openstudio {
namespace model {

// AirCondVRF, reimplemented from ModelHVAC.i
std::vector<ZoneHVACTerminalUnitVariableRefrigerantFlow> terminals(const openstudio::model::AirConditionerVariableRefrigerantFlowFluidTemperatureControl& airCondVRF) {
return airCondVRF.terminals();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example of missing partial classes

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

@MingboPeng @arif-hanif the test step is failing, I wonder if you can help, as I don't understand the C# ecosystem enough to be honest.

I think this is just because GHA (or the default .NET installer for that matter) updated their default .NET to be 8.0.0 and above, and we try to test something targeting .NET 7.0

/Users/runner/.dotnet/sdk/9.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(254,5): warning NETSDK1201: For projects targeting .NET 8.0 and higher, specifying a RuntimeIdentifier will no longer produce a self contained app by default. To continue building self-contained apps, set the SelfContained property to true or use the --self-contained argument. [/Users/runner/work/OpenStudio/OpenStudio/csharp/examples/OpenStudio.Tests/OpenStudio.Tests.csproj::TargetFramework=NET7]
  OpenStudio.Tests -> /Users/runner/work/OpenStudio/OpenStudio/csharp/examples/OpenStudio.Tests/bin/x64/Debug/net7/osx-x64/OpenStudio.Tests.dll
Test run for /Users/runner/work/OpenStudio/OpenStudio/csharp/examples/OpenStudio.Tests/bin/x64/Debug/net7/osx-x64/OpenStudio.Tests.dll (.NETCoreApp,Version=v7.0)
VSTest version 17.13.0 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) '/Users/runner/work/OpenStudio/OpenStudio/csharp/examples/OpenStudio.Tests/bin/x64/Debug/net7/osx-x64/OpenStudio.Tests.dll' exited with error: You must install or update .NET to run this application.
App: /Users/runner/work/OpenStudio/OpenStudio/csharp/examples/OpenStudio.Tests/bin/x64/Debug/net7/osx-x64/testhost.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
.NET location: /Users/runner/.dotnet/
The following frameworks were found:
  8.0.1 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App]
  8.0.4 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App]
  8.0.7 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App]
  8.0.14 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App]
  9.0.1 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App]
  9.0.3 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=osx-x64&os=osx.13
. Please check the diagnostic logs for more information.

https://github.com/NREL/OpenStudio/actions/runs/14214305608/job/39834389714#step:5:66

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

Actually the question might be whether we shouldn't bump the target from .NET 7 to .8 or above.

Seems like it's EOL https://dotnet.microsoft.com/en-us/download/dotnet/7.0/runtime?cid=getdotnetcore&os=macos&arch=x64

image

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

Ok I found where this is defined:

<TargetFrameworks>NET7</TargetFrameworks>

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

is this ok though?

<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">NET45;netstandard2.0</TargetFrameworks>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFramework>

That seems awfully outdated?

Are there any gains for bumping it to NET8 for eg?


<PropertyGroup>
<TargetFrameworks>NET7</TargetFrameworks>
<TargetFrameworks>NET7;NET8;NET9;NET10</TargetFrameworks>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my attempt at fixing the C# test step, just allow whatever is on the GHA runner.

Launch a run at https://github.com/NREL/OpenStudio/actions/runs/14217768843

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this would allow testing with ANY version installed in that list, but it seems that it tries to do ALL of them so the workflow is probably going to fail.

  Determining projects to restore...
/usr/lib/dotnet/sdk/8.0.114/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(166,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0.  Either target .NET 8.0 or lower, or use a version of the .NET SDK that supports .NET 9.0. Download the .NET SDK from https://aka.ms/dotnet/download [/media/DataExt4/Software/Others/OS-build-csharp2/Testing/csharp/OpenStudio.Tests/OpenStudio.Tests.csproj::TargetFramework=NET9]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEH, just going to use NET8 and keep move on for now.

Launched at https://github.com/NREL/OpenStudio/actions/runs/14218506478

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that run worked, including testing.

@MingboPeng
Copy link
Contributor

Hi @jmarrec, yes, Github Action disabled the .Net 7 by default. Just updating the test project to .Net 8 will just be fine.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

@joseph-robertson A quick look from you would be nice please. It's ready to drop in.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 2, 2025

is this ok though?

<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">NET45;netstandard2.0</TargetFrameworks>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFramework>

That seems awfully outdated?

Are there any gains for bumping it to NET8 for eg?

@MingboPeng is there a gain to be had, or is it better to keep targeting old versions so it's compatible with pretty much anything?

@MingboPeng
Copy link
Contributor

Hi @jmarrec,
netstndard2.0 will be fine for latest version of .NetCore.

https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
image

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 13 changed files in this pull request and generated no comments.

Files not reviewed (12)
  • csharp/examples/OpenStudio.Tests/OpenStudio.Tests.csproj: Language not supported
  • csharp/examples/OpenStudio.Tests/OpenStudio.Tests.x86.csproj: Language not supported
  • src/alfalfa/Alfalfa.i: Language not supported
  • src/model/ModelCore.i: Language not supported
  • src/model/ModelGeometry.i: Language not supported
  • src/model/ModelHVAC.i: Language not supported
  • src/model/ModelResources.i: Language not supported
  • src/model/ModelZoneHVAC.i: Language not supported
  • src/utilities/filetypes/Filetypes.i: Language not supported
  • src/utilities/filetypes/WorkflowStep.cpp: Language not supported
  • src/utilities/filetypes/WorkflowStep.hpp: Language not supported
  • src/utilities/xml/XMLValidator.i: Language not supported

@jmarrec jmarrec merged commit 8abc1f6 into develop Apr 25, 2025
13 checks passed
@jmarrec jmarrec deleted the hotfix/5365 branch April 25, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component - C# Developer Issue Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants