Giter Club home page Giter Club logo

Comments (3)

daveaglick avatar daveaglick commented on September 15, 2024

A couple things going on here, I think.

The first is that IOperation appears to be an "unshipped" API (at least for the version of Roslyn we're currently using). See dotnet/roslyn-analyzers#1028 (comment) and http://david.gardiner.net.au/2016/08/error-ad0001-compiler-analyzer-threw.html. Unfortunately, I can't currently update Roslyn due to compatibility concerns with VSIX and MsBuild tasks and I don't want to manually enable an unshipped feature.

Secondly though, I'm not sure this is actually going to do what you want anyway. When you say you're trying to call a method, do you mean you want to evaluate something that's part of your project (and not the Scripty script)? If so, that gets tricky anyway. Scripty runs in it's own process space and the scripts are evaluated at build-time (or design-time if using the custom tool). At that stage, your own application is just a collection of source code. In fact, your own application hasn't even been compiled into an assembly yet (at least not beyond what Roslyn does to construct the workspace) so there really isn't a "static public property" to call yet (at least not in the sense that there's associated IL that can be evaluated). Hopefully that made sense...

from scripty.

managedcoder avatar managedcoder commented on September 15, 2024

@daveaglick,
Bummer about the unshipped IOperation API! Let me explain quickly what I am trying to do which will provide some context and address your second point. I have a VS project template that produces an Azure Mobile App that has authentication, push notification, and data sync for offline usage all wired up in a way that allows the developer to choose which features/capabilities they want to light up. Depending on what the developer wants to light up, certain SDK types will be different (IMobileServiceTable or IMobileServiceSyncTable, for example) so I am using Scripty to generate the proper types in a partial class depending on how a Capabilities class is configured. This is the same Capabilities class is used by the project code generated by the project template which directs the boiler plate code in proper operation depending on what capabilities are desired (e.g. check the push notification capability in boiler plate code before attempting to send a push notification because dev may not have choosen to configure PN for the app).

So this needs to be a build-time code generation scenario so that when the developer chooses the capabilities they want the proper code is generated for the partial class that has proper types and such generated. If the developer later changes their mind and decides to light up push notifications or offline data sync support the proper code will be generated on the next build.

from scripty.

daveaglick avatar daveaglick commented on September 15, 2024

I can think of three ways this could potentially be tackled:

  • Put the Capabilities class in a separate library that gets consumed both by your application and by Scripty using an #r directive. If you do that, Scripty has access to any objects in the referenced library the same way any code would and can evaluate whatever you need it to.
  • Place the configuration inside a JSON/XML/text/etc file that both Scripty and your application can read. Have Scripty read it and then generate what's needed based on it's content. Your application could read it and then instantiate or otherwise initialize whatever state you need to based on it.
  • Use the semantic model to see what the Capabilities class looks like. You won't be able to evaluate anything, but if you're just trying to figure out what it contains, you shouldn't need to.

Hopefully one of these approaches will get you what you need!

from scripty.

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.