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

Add visualization for a couple of QuantLib types in Visual Studio debugger #1028

Merged
merged 2 commits into from
Feb 14, 2021

Conversation

igitur
Copy link
Contributor

@igitur igitur commented Feb 10, 2021

As discussed in https://sourceforge.net/p/quantlib/mailman/message/37162962/

I see the embedded images were removed in the mailing list. That's a pity.

Anyway, the added Quantlib.natvis file enables better visualisation of QuantLib types in Visual Studio.

image

@lballabio lballabio added this to the 1.22 release milestone Feb 10, 2021
@lballabio
Copy link
Owner

Is it enough to add them to the QuantLib project, or should they be added to the test-suite and examples as well?

@coveralls
Copy link

coveralls commented Feb 10, 2021

Coverage Status

Coverage decreased (-0.2%) to 70.82% when pulling 247fe71 on igitur:add-natvis-file-for-visualstudio into dcc2d4f on lballabio:master.

@ralfkonrad
Copy link
Contributor

@igitur: Definitely something a VS programmer wants to have!

Does

<DisplayString>{year():0000}-{month():00}-{day():00}</DisplayString>

work as well and produces 2015-09-07?

This would be in line with

//! output dates in ISO format (yyyy-mm-dd)
/*! \ingroup manips */
detail::iso_date_holder iso_date(const Date&);

in date.hpp and personally I find it easier to read.

@igitur
Copy link
Contributor Author

igitur commented Feb 14, 2021

Is it enough to add them to the QuantLib project, or should they be added to the test-suite and examples as well?

It's sufficient to add it only to the QuantLib project. I tested the test-suite and an example project. Works 100%.

@igitur
Copy link
Contributor Author

igitur commented Feb 14, 2021

@igitur: Definitely something a VS programmer wants to have!

Does

<DisplayString>{year():0000}-{month():00}-{day():00}</DisplayString>

work as well and produces 2015-09-07?

This would be in line with

//! output dates in ISO format (yyyy-mm-dd)
/*! \ingroup manips */
detail::iso_date_holder iso_date(const Date&);

in date.hpp and personally I find it easier to read.

I agree. I also tried to find format specifiers to achieve this, but couldn't. The format specifiers you mention also don't work. But I managed to do it with some integer maths where the tens and units parts are calculated separately. Update pushed.

@lballabio lballabio changed the title Add QuantLib.natvis to Visual Studio project Add visualization for a couple of QuantLib types in Visual Studio debugger Feb 14, 2021
@lballabio lballabio merged commit d828b36 into lballabio:master Feb 14, 2021
@igitur igitur deleted the add-natvis-file-for-visualstudio branch February 14, 2021 20:12
@igitur
Copy link
Contributor Author

igitur commented Feb 14, 2021

@ralfkonrad If you can think of other classes that could use special visualisation, please let me know.

@ralfkonrad
Copy link
Contributor

It's sufficient to add it only to the QuantLib project. I tested the test-suite and an example project. Works 100%.

I guess this is because the "full" QuantLib project is referenced in the testsuite and examples:

<ProjectReference Include="..\QuantLib.vcxproj">

Therefore the natvis is forewarded as well.

I have not tested it yet but I do not expect it to work out of the box using CMake VS projects as the natvis will not be picked up.

@ralfkonrad
Copy link
Contributor

If you can think of other classes that could use special visualisation, please let me know.

For me the Date visualisation is a gamechanger. Normally I ended up copying the serialNumber_ into Excel to convert into a readable date.

Other special visualisations might be

  • Period if it is possible to convert the enum TimeUnit into e.g. 3Y.
  • InterestRateIndex by showing the std::string name_;.
  • InterestRate by just showing the Rate r_;

Besides that I think it will not work in a couple of interesting classes like DayCounter, Currency, Calendar as you do not have access to the name_ in the inner implementation.

@ralfkonrad
Copy link
Contributor

@igitur I am not sure if you get informed about a comment on a closed PR without being mentioned, therefore this additional comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants