简体   繁体   中英

Consider all types in external dll as nullable with C# Nullable reference types

I use C# Nullable reference types in my project and I have reference to some other dll that does not support Nullable reference types.

Can I somehow tell compiler that all properties in external dll can be null? By default compiler show all as not null.

Values from unannotated code are treated as 'oblivious', meaning their nullability is unknown. Analysis for such values behaves in the same way as before the NRT feature existed.

You should not need to disable the nullable context for code that consumes that library. You just wont gain any insight into where nulls may flow into your code, and where nulls may be incorrectly passed to that external code.

Ideally you would obtain an annotated version of the assembly. If it has a small enough surface area, you could provide your own an annotated shim.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM