-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/unsafe-evolution.md
Proposal issue: dotnet/csharplang#9704
Feature branch: https://github.com/dotnet/roslyn/tree/features/UnsafeEvolution
-
MemorySafetyRulesattribute- opt-in (via compilation options)
- MemorySafetyRulesAttribute synthesized if missing (see
Extern_*) - Disallow MemorySafetyRulesAttribute on source modules (see
RulesAttribute_ReferencedInSource) - LangVer (need test like
RulesAttribute_Synthesizedbut with LangVer)- LangVer and extern (see
Extern_Method)
- LangVer and extern (see
- loaded from metadata
- Operations:
- pointer indirection (see
Pointer_Dereference_*) - pointer member access (see
Pointer_MemberAccess_*) - pointer element access (see
Pointer_ElementAccess_*) - function pointer invocation (see
Member_FunctionPointer) and conversion (seeMember_Method_ConvertToFunctionPointer) - access on fixed-sized buffer (see
FixedSizeBuffer_*) - stackalloc conversion (see
StackAlloc_*) - property and method usage:
- extensions
- operator, extension operator (see
Member_Operator_*) - attribute (see
Member_Property_Attribute) - function types (missing?)
- object initializers,
withexpressions -
nameof(seeMember_Method_NameOf) - ...
- indirect usages:
- variations of
Currentinforeach(seeMember_Current_*), - variations of
Disposeinusing(seeMember_Dispose_*), -
Deconstructin deconstructino (seeMember_Deconstruct), - various member in
lock(seeMember_LockObject), - interpolation handlers (see
Member_InterpolatedStringHandler) - interceptors (see
Member_Interceptor, we only check intercepted) - patterns
- ...
- variations of
- constructor usage:
- object creation
- this/base (see
Member_Constructor_This) - attribute (see
Member_Constructor_Attribute)
- pointer indirection (see
- [RequiresUnsafe]
- round-trip "caller unsafe" flag using
RequiresUnsafeAttribute - disallowed on lambda (see
Member_Lambda), static constructors and finalizers (seeRequiresUnsafeAttribute_ReferencedInSource) - warn in legacy mode (see
RequiresUnsafeAttribute_ReferencedInSource) - partial (missing tests?)
- on extern (see
Extern_Method_Explicit) - LangVer
- round-trip "caller unsafe" flag using
- OHI (see
*_Override,*_Implementation,*_Hiding,Extern_Method_Override) -
unsafe- alias directives (missing warning, see
*_UsingAlias_*) -
using staticdirectives (missing tests?)
- alias directives (missing warning, see
- mark public APIS a [Experimental]
- update compiler test plan
- Ping F# and C++/CLI team as FYI
- Add attributes to BCL
-
MemorySafetyRulesAttribute -
RequiresUnsafeAttribute
-
- how should the compiler deal with well-known members that are unexpectedly marked as caller-unsafe? (some are ok, such as
UnsafeHelpersfor inline arrays, but what about others?) - PROTOTYPE comments
- spec open issues
- breaking changes?
- LangVer tests should include C#Next
- Should reflection APIs be requires-unsafe? Or should there be a runtime check (must use special flag or API to access unsafe APIs)?[/-]
- Should
Activator.CreateInstance<T>()be requires-unsafe?[/-] - Should
dynamicbe marked as requires-unsafe?
Reactions are currently unavailable