Comments (3)
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.
@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.
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)
- After installing scripty tool VS2017 is broken HOT 1
- Can't set the custom tool HOT 2
- Auto run custom tool when *.cs document saving HOT 3
- Making Scripty.MsBuild run only within a single build configuration HOT 5
- Cake.Scripty references an older version of Cake.Core
- Scripty doesn't work in SDK-style projects HOT 6
- Potential problems with outputting to source folder HOT 1
- Scripty.MsBuild settings encoding problem
- Scripty still runs even if file is excluded from project HOT 3
- Recommended changes resulting from automated audit HOT 1
- Extension fails to work in 15.8 Preview 3 HOT 19
- How to use System.Data namespace in .csx File HOT 1
- Scripty Extension Page Not Found HOT 1
- Trouble with referenced third-party libraries HOT 2
- Scripty Visual Studio extension URL is not working HOT 2
- Dead Project ? HOT 1
- Visual studio extesion no longer available + does not work in .net core 2.1, 2.2
- Is this project dead? What do we use to generate code with .NET Core 3.1? HOT 1
- Works on Windows, fails on Linux.
- create a source generator to replace scripty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scripty.