Source Generator for Web Service #50568
Replies: 4 comments 6 replies
-
Can you explain what exactly do you mean? What is the full error message you're getting? I can't think of anything specific to Roslyn that would prevent you from generating code that uses |
Beta Was this translation helpful? Give feedback.
-
I would strongly recommend not doing this. This will have an extremely negative effect on the VS ide. You will effectively be doing unbounded network IO in a codepath that needs to run in sub-ms time max. Every time completoin comes up, this will be causing blocking network requests to happen, which will certainly impact hte ability for anyone using this generator to do basic stuff: like type. Tagging @jasonmalinowski @chsienki for visibility and so we can provide appropriate docs steering people away from doing this. @jasonmalinowski it will likely be very necessary for us to collect metrics on misbehaving generators so we can let people know why their performance is potentially tanking. |
Beta Was this translation helpful? Give feedback.
-
For me, this isn't a problem as the code being generated does nothing but
inject a static constructor into a partial class. So there is nothing for
the IDE to need to try and reflect.
And from what I have seen of how aggressive VS caches the output from the
Source Generator, I can't see it really being that much of a problem.
The project this source generator is for is internal use, not public
release. It will basically wind up having it's builds automated, only
invoked when the dataset changes, causing an updated nuget package to be
created and pushed to my nuget repository.
I also have a static variable with the dataset stored in a class, and it
gets fetched during the Initialize method ONLY if the static dataset isn't
present. So my typing experience hasn't suffered at all given the fetch
only ever happens once during the lifetime of the Source Generator's
process.
A few extra seconds during the compilation process doesn't matter either, I
am using the Source Generator because it's portable and integrated into the
compile process.
Now if I can only just get this dependency problem to go away. I think that
would be a better place to focus some time rather than writing some
documents to say don't do unbound network IO.
In fact given that it is actually quite reasonable to expect some Source
Generators may need to do some lengthy operations during their
initialization phase, having a way to do this asynchronously would be
helpful.
…On Mon, 18 Jan 2021, 10:43 CyrusNajmabadi, ***@***.***> wrote:
When I use the source generator in my build I am unable to make the
required Rest API calls via HttpClient.
I would strongly recommend *not* doing this. This will have an extremely
negative effect on the VS ide. You will effectively be doing unbounded
*network* IO in a codepath that needs to run in sub-ms time *max*. Every
time completoin comes up, this will be causing blocking network requests to
happen, which will certainly impact hte ability for anyone using this
generator to do basic stuff: like type.
Tagging @jasonmalinowski <https://github.com/jasonmalinowski> @chsienki
<https://github.com/chsienki> for visibility and so we can provide
appropriate docs steering people away from doing this.
@jasonmalinowski <https://github.com/jasonmalinowski> it will likely be
*very* necessary for us to collect metrics on misbehaving generators so
we can let people know why their performance is potentially tanking.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#50568 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJAS34TOL3PYBPTMHAT2MKDS2NYZJANCNFSM4WF4MILA>
.
|
Beta Was this translation helpful? Give feedback.
-
The ide doesn't know this.
Any caching is currently a bug. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am developing a source generator for a project that takes data pulled from a Rest API and builds the appropriate code to match said data.
Using a Console Application I was able to successfully test my source generator by mocking up the ISourceGenerator GeneratorExecutionContext and GeneratorInitializationContext classes, and ensured the Source Generator is working as expected.
When I use the source generator in my build I am unable to make the required Rest API calls via HttpClient.
I have found reference to HttpClient not being allowed due to security policy. What is the point of developing and opening up this API for use by all developers if we cannot use it the way we need to?
Is there any way to be able to allow calls via HttpClient or work around this limitation in some way?
Regards,
Robert Heffernan
Beta Was this translation helpful? Give feedback.
All reactions