-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Enable generic attributes #16814
Enable generic attributes #16814
Conversation
Thanks for the PR! FYI @mattwar |
@jcouv |
@AviAvni Let me get back to you. |
From discussion with @jaredpar and @VSadov, the only way to have a compiler feature be conditional on runtime is to have some kind of API marker (type or method) in corlib, which the compiler can test for. A couple of language questions that need to be discussed/resolved with LDM (@mattwar will drive):
|
|
@jcouv thanks for the help |
Perhaps @jkotas wants to weigh in here. There are a number of new runtime features we are looking at adding. For every one of them that has compiler support we're going to need an API marker in order for the compiler to enable support. |
I think that the nature of this issue is similar to ref locals and returns. ref locals and returns are not keyed by any API. They should work just fine with existing runtimes, tools and libraries in theory. In practice, they do not work just fine because of they expose pre-existing bugs and limitations because of the paths handling them were never exercised, or they were explicitly not expected. The bugs and issues related to byref returns are just starting to show up as people are starting to use the feature and finding places where it does not work. I think that is fine and expected. We should acknowledge it, and not react to it by pulling back the feature like we have done it for default valuetype constructors some time ago. This feature is pretty similar. There is nothing in ECMA that prohibits generic attributes, and they should work just fine in theory. In practice, they do not. Number of parts throughout the system have to be updated to make them work well:
I would not hurt to run this feature through API review to get peoples opinions on how to deal with this. It is not strictly a new API right now, but it affects number of existing APIs, there may be new APIs needed, and we will need rules on where to use the generic attributes vs. the classic non-generic ones. cc @terrajobst @KrzysztofCwalina @karelz |
Definitely don't want to pull back the feature. I'm more looking for a way to enable it more reliably.
Is there any existing runtime though where generic attributes work? |
It depends on which reflection API you use. If you use It would be useful to find out what works and what does not accross different runtimes. |
@AviAvni Have you tried the compiler change in combination with any other runtimes than the CoreCLR (Full framework, Mono, or CoreRT)? Regarding your question about VB, yes, it is good to add support across the board. But let's make sure we iron out the issues with C# and runtime first. |
@jcouv full framework I get exception you can see https://github.com/dotnet/coreclr/pull/9189/files#diff-1f1dd1552f4465a1fff8bd2460eab007L701 coreclr same |
Thanks @AviAvni for the information. @jkotas Given that this doesn't work on full framework or coreclr, I agree with Jared that we need to shield this feature with some kind of runtime marker. For this purpose, we could simply use an enum type. This would be extensible, as we expect we will need such markers as more compiler/runtime features ship. What do you think? |
This is not 100% correct statement. It works if you use However, I agree that similar marker may be useful in general. So if you believe that we really need it here, feel free to turn in into API proposal: https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md |
FYI, I made an API proposal for an enum listing features supported by the runtime: https://github.com/dotnet/corefx/issues/17116 |
it's been failing
merge from master
Not all of our desktop tests have a target framework directory in their paths. Only the ones which also multi-target do. For the time being changing the set of DLLs that we run on Mono to be a hard coded list as it's only two. Will expand out as we increase our scope.
merge from master
@jcouv it's look like I can't use RuntimeFeature class now do I need to update something? |
@AviAvni I thought we already have a dependency on the API, but I'll double-check (https://github.com/dotnet/corefx/issues/19788#issuecomment-363235102). |
Confirmed that Roslyn isn't using Going back to the design notes: to check statically the compiler needs to probe for well-known member |
@jcouv Thanks so just to be sure only checking the member exists and without calling the Is supported method? So why need this method? |
@jcouv And I finished the PR Of coreclr it will be merge after version 2.1 |
The method is there for runtime detection, like runtime code generation. We expect that to be uncommon scenario. |
@jcouv thanks |
It doesn't look like dotnet/csharplang#124 has been approved by LDM. Also, I believe this work should be done in a feature branch. See https://github.com/dotnet/roslyn/blob/master/docs/contributing/Developing%20a%20Language%20Feature.md for more information. |
Created feature branch |
@jcouv I changed the PR target to dotnet:features/generic-attributes |
@jcouv the coreclr pr just merged how we can continue? |
@AviAvni I'm trying to reload some context. Here's where I think we stand:
If I were you, I'd consider closing this PR and opening a new one, as we don't often look at PRs at the tail of the list. |
@jcouv Thanks I'll open new pr soon |
Implements feature proposal #953
Succesfully compile and run https://gist.github.com/AviAvni/00831abbddf4ceca198236de362ed449
Depend on: dotnet/coreclr#9189