
Microsoft plans to change C# memory-safety labeling so potentially unsafe operations are more clearly indicated. The unsafe keyword will function as an explicit contract rather than a broad marker. Pointer operations and other unsafe actions must occur within separate unsafe blocks. Methods that pass unsafe behavior to other parts of an application must be explicitly declared unsafe. The unsafe label will propagate to calling code, making dependencies on risky memory operations easier to identify. Overrides will not be marked unsafe when the base method is safe. Entire types will no longer be marked unsafe; scope will move to individual methods, properties, and fields. Pointer types will not automatically be unsafe; unsafe context will arise only when unmanaged memory is accessed through pointer dereferencing.
"Microsoft wants to change this by treating "unsafe" more as an explicit contract. Specifically, this means that pointer operations and other unsafe actions must take place within a separate "unsafe" block. Methods that pass such risks to other parts of the application must also be explicitly declared as "unsafe.""
"Under the new model, the unsafe label also propagates to code that calls such functions, explains The Register. This makes it easier to see which parts of an application depend on potentially risky memory operations. According to current proposals, for example, overrides will no longer be marked as unsafe if the base method is considered safe."
"Microsoft also aims to further refine the use of "unsafe." It will no longer be possible to mark entire types as "unsafe." That scope will shift to individual methods, properties, and fields. Pointer types themselves will also no longer be automatically considered unsafe."
"An unsafe context will only arise when code actually accesses unmanaged memory via pointer dereferencing. With this, Microsoft is attempting to more precisely distinguish between high- and low-risk operations. AI code increases the importance of verificatio"
Read at Techzine Global
Unable to calculate read time
Collection
[
|
...
]