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
SWIG C# fixes + dotnet support #3960
Conversation
Iteration
Updating master for 2.9.0 release
Updating to v2.9.1
cwstring.i is only implemented for python and tcl really.
… default constructor, so make one
Swig isn't happy if you do two typedef/templates for the same stuff (std::pair<std::string, std::string> here)
…e hiding inherited ```` Severity Code Description Project File Line Suppression State Warning CS0108 'MasslessOpaqueMaterial.iddObjectType()' hides inherited member 'ModelObject.iddObjectType()'. Use the new keyword if hiding was intended. [D:\OpenStudio\build-vs\csharp_wrapper\OpenStudio.csproj] csharp_sdk D:\OpenStudio\build-vs\csharp\generated_sources\OpenStudioModelResources\MasslessOpaqueMaterial.cs 81 ```
…ecated declarations to C#
…at causes multiple definitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait for #3960 to go in first.
csharp/OpenStudio.nuspec.in
Outdated
<file src="@OPENSTUDIO_CSHARP_DLLNAME@" target="lib" /> <!-- TODO: target should be lib\{framework}, eg `lib\netcoreapp3.0` --> | ||
<file src="@OPENSTUDIO_CSHARP_LIBNAME@" target="build" /> <!-- target to 'build' is probably not right either --> | ||
<file src="@OPENSTUDIO_MODEL_CSHARP_LIBNAME@" target="build" /> | ||
<file src="@OPENSTUDIO_TRANSLATORS_CSHARP_LIBNAME@" target="build" /> | ||
<file src="@OPENSTUDIO_MODEL_CSHARP_LIBNAME@" target="build" /> <!-- TODO why is this repeated? --> | ||
<file src="@PROJECT_SOURCE_DIR@/csharp/OpenStudio.targets" target="build" /> <!-- To copy native binaries --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openstudio_model_csharp.dll
is added twice?
csharp/OpenStudio.targets
Outdated
<Copy SourceFiles="@(NativeBinary)" | ||
DestinationFiles="@(NativeBinary->'$(OutDir)\%(TargetPath)\%(Filename).so')" | ||
Condition="'%(Extension)'=='.so'"> | ||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" /> | ||
</Copy> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try support for *.so
files on Unix.
set(CSHARP_VERSION_PATCH ${PROJECT_VERSION_PATCH_DIGIT}) | ||
set(CSHARP_VERSION_BUILD 0) | ||
|
||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://cmake.org/cmake/help/latest/variable/CMAKE_CL_64.html
Discouraged. Use CMAKE_SIZEOF_VOID_P instead.
Set to a true value when using a Microsoft Visual Studio cl compiler that targets a 64-bit architecture.
# TODO: there are probably adjustments to make to OpenStudio.csproj_dotnet.in | ||
# The Release/Debug can be stripped probably | ||
# Also probably don't need to use multiple `<TargetFrameworks>` which is the reason there's an extra netcoreapp3.0/ level | ||
set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/netcoreapp3.0/OpenStudio.dll") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what to do there.
install(TARGETS openstudio_csharp DESTINATION CSharp/openstudio/ CONFIGURATIONS RELEASE COMPONENT "CSharpAPI") | ||
add_library( | ||
openstudio_csharp | ||
SHARED # Was "MODULE" on Windows before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't remember why I had to change that to "SHARED" instead of "MODULE", not 100% sure the impact it'll have.
// Ignore the ostream operator<<, for CSharp where it'll throw a multiple definition | ||
%ignore openstudio::operator<<; | ||
%ignore openstudio::model::operator<<; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for the CSharp_OpenStudio_LeftShift__SWIG_1 multiple definitions.
…name of the generated library file (in ProjectMacros) IT WORKS!
…udio_model_csharp
|
std::string m_componentTypeName; | ||
std::string m_controlTypeName; | ||
}; | ||
|
||
/** Simple class for ScheduleTypeRegistry key. \relates ModelObject */ | ||
class MODEL_API ScheduleTypeKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I see you changed the type of ScheduleTypeKey from std::pair. But this is a breaking API change. I wouldn't complain except I also saw that the std::pair was even deliberately swigged. So we shouldn't take this change lightly. Is it the only way? If so then at least we should say something in release notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not mandatory, but much cleaner, and it does fix a C# bindings issue with an improperly wrapped type. There are multiple occasions where std::pair<std::string, std::string>
was defined to something that was clashing too if I recall correctly.
Like src/utilities/core/Containers.hpp:58:typedef std::pair<std::string,std::string> StringPair;>
Adding it to the release notes would make sense.
I doubt anyone uses ScheduleTypeKey
much anyways, this stuff is meant to be used by the ScheduleRegistry internally, not messed with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree on all of your points. Can you just add a comment in the release notes and then I'll just go ahead and merge? I think you will have to start a new file https://github.com/NREL/OpenStudio/tree/develop/developer/doc/ReleaseNotes for version 3.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VersionString::VersionString(const std::string& version) | ||
: m_str(version) | ||
{ | ||
bool VersionString::parseVersionString(const std::string& version) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes to VersionString all cosmetic formatting changes, or is there a functional change hidden in here?
@@ -114,6 +114,10 @@ class UTILITIES_API VersionString { | |||
public: | |||
explicit VersionString(const std::string& version); | |||
|
|||
// Default constructor, assumes the current OpenStudio::openStudioLongVersion is passed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think here is the new functional thing. Makes sense.
Hi @jmarrec, could you please share the C# sdk for Ubuntu? I am trying to refactor the Ironbug to make it dotnet core compatible, and run on Ubuntu. I cannot really figure out how to compile the OpenStudio C# SDK on Ubuntu. Could you please provide some insights? Thanks, |
@MingboPeng You should only need to install dotnet-sdk on ubuntu, and enable BUILD_CSHARP_BINDINGS=ON in CMake. I can walk you through it via slack (On UnmetHours' slack for eg) if you want. |
With @jmarrec 's help, I can confirm that C# bindings works on my Ubuntu as well. Nice work! |
Great news and Congrats on being the first person to try it out :D |
Hi @jmarrec, I am starting to build a Github workflow (CI) to automatically build this CSharpSDK on Ubuntu. But I got a several issues:
https://github.com/MingboPeng/OpenStudio/runs/1278780180?check_suite_focus=true#step:5:613
Please let me know if I missed anything. |
@MingboPeng Use 20.04 isn't officially supported, we officially support 18.04! For 2., it's number 1. that's causing the error. Just because CMake says it didn't configure properly after a ruby message doesn't mean it's from ruby. the CMake Error due to file download hash mistmatch is likely the root cause instead. |
I've made some edits to your buildCsharp.yml github action file in a PR at MingboPeng#1 |
Thanks @jmarrec, on ubuntu, I think all works now. I am also trying to compile it on Mac, but got following error that I can't resolve. It failed to find the compiler while the c compiler exists. https://github.com/MingboPeng/OpenStudio/runs/1290457540?check_suite_focus=true#step:7:17 Thanks again for your time. |
Pull request overview
This includes #3959 which are generally SWIG improvements for C#, and also adds
dotnet
support so one can build the C# bindings on Unix for eg.Status:
PackageReference
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)src/openstudio_lib/library/OpenStudioPolicy.xml
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.