question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using C#-like syntax for `dynamic` (and other keywords that compile to attributes)

See original GitHub issue

Would you be interested in showing [System.Runtime.CompilerServices.DynamicAttribute()] object as dynamic, similar to the C# syntax that you’d see in intellisense when interacting with the API?

An argument against it might be that it’s better to put lower-level realities in your face in case the API is used from a language where the attribute is not specially-recognized.

Maybe an argument for it would be that it would be consistent with [ParamsAttribute], [ExtensionAttribute], etc, and the same kind of thing with C# 8 attributes: https://github.com/ApiApprover/ApiApprover/issues/54

A few other attributes have cropped up like the ones for the C# 7.0 ref and readonly keywords when declaring a struct:

public readonly ref struct Foo
{
}

Desugared:

[IsByRefLike]
[Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
[IsReadOnly]
public struct Foo
{
}

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA+ABAzAAlgQwBMIA7AGwE88YAzHAZwBcoBXMRnAMQggFgAoAN4CAvkA=

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jnm2commented, Nov 2, 2019

I think that volatile itself is not a part of api. It is just implementation detail.

The modreq indicates how important it is as API. Modreqs are how you can express “this object requires special handling.”

If you access a volatile field, the compiler emits a volatile. prefix before the stfld/ldfld instructions. It should show up in a dramatic way in your public API if the volatility changes because it’s a breaking change. It’s a binary behavioral breaking change because libraries compiled against an older version of your library will not use volatile. when they should, and it’s a compile-time break because errors begin showing up if you take a ref to a suddenly-volatile field.

(Happy to open a separate issue though.)

0reactions
sungam3rcommented, Nov 13, 2020

Unfortunately, I don’t remember anything about dynamic gist at all. Perhaps the point is that dynamic is encoded in a special way, something like NRT: https://sharplab.io/#gist:a135eb77630b190590b751c7af429743

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attributes in Clang — Clang 18.0.0git documentation
The swift_error attribute controls whether a particular function (or Objective-C method) is imported into Swift as a throwing function, and if so, which...
Read more >
6.30 Declaring Attributes of Functions
The keyword __attribute__ allows you to specify special attributes when making a declaration. This keyword is followed by an attribute specification inside ...
Read more >
Using type dynamic
Learn how to use the dynamic type. The dynamic type is a static type, but dynamic objects bypass static type checking.
Read more >
attributes in C++
Attributes are one of the key features of modern C++ which allows the programmer to specify additional information to the compiler to ...
Read more >
Attributes - Documentation - Swift.org
If you implement both dynamicallyCall methods, dynamicallyCall(withKeywordArguments:) is called when the method call includes keyword arguments. In all other ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found