Giter VIP home page Giter VIP logo

Comments (5)

govert avatar govert commented on June 27, 2024

ExplicitExports should definitely be 'false' by default and should be 'false' in the .dna template by default - this makes the VB situation friendlier, and is compatible with the past.

However, I'm happy to have the template in the NuGet package include both the ExplicitExport='false' tag, and a comment that describes the situation. So anything like this:

<DnaLibrary Name="%ProjectName% Add-In" RuntimeVersion="v4.0">
  <ExternalLibrary Path="%OutputFileName%" LoadFromBytes="true" Pack="true" ExplicitExports="false" />

<!-- ExplicitExport indicates whether exported function and macros need to be explicitly marked with [ExcelFunction(...)] and [ExcelCommand(...)] macros to be exported, or whether all public static methods with compatible signature are registered.
The behavior is as follows: .....

Read more here:....

-->
</DnaLibrary>

from exceldna.

augustoproiete avatar augustoproiete commented on June 27, 2024

@govert: Could you expand on the "makes the VB situation friendlier" part? Is there a difference between C# and VB with regards to the exports of functions?

Adding the attribute to the .dna template, even if false by default, seems like a step in the right direction to me, so 👍.

I do, however, think would be nice to go a little bit further and - at least - declare it as true for newly created add-ins, and thus still staying compatible with existing add-ins.

from exceldna.

govert avatar govert commented on June 27, 2024

I mean for somebody coming from VBA, it's pretty cool that the basic code can look like this

Public Module MyFunctions
    Function AddThem(v1, v2)
        AddThem = v1 + v2
    End Function
End Module

It's bad enough that you need the Public Module ... around it, but at least you don't need to know about attributes to get started.
I value that enough, together with the backward compatibility, to want to keep the default 'false'.

from exceldna.

augustoproiete avatar augustoproiete commented on June 27, 2024

Got it.

I see your point re: simplicity, but I honestly question if that is "real code" vs "demo code".

I've never seen a real-world add-in that simple, where every function is self-contained and don't call other utility functions to get some reuse.

As soon as you get into something almost as simple:

Public Module MyFunctions
    Function Calculate(v1, calcType)
        denominator = GetDenominator(calcType)
        Calculate = v1 / denominator
    End Function

    Function GetDenominator(calcType)
        Case calcType = "x"
            GetDenominator = 10
        Case calcType = "y"
            GetDenominator = 20
        Default
            GetDenominator = 1
    End Function
End Module

You're in trouble... As GetDenominator now is exposed to the world and your public API surface is bigger than you wanted it to be - and by the time you notice it, it could be too late and people are already using GetDenominator in their spreadsheets.

Now imagine you have 50 methods that got exposed unintentionally, instead of one... 50 more methods to support / keep backwards compatibility, etc. than you originally planned for.

So in general, I think being explicit on what you make public to the user, leads to a better design.

Anyway, having the attribute in the template is still a good improvement.

from exceldna.

govert avatar govert commented on June 27, 2024

Check-in 37326da adds the ExplicitExports="false" to the .dna file template.

from exceldna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.