✅ Unsafe code
Can somebody explain why this needs UNSAFE
I am getting a json back from firebase firestore

9 Replies
Are you targeting WinRT?
Could you share the csproj file?
I am unfamiliar with WinRT but my cursory research suggests that you're targeting
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework>
or similar, and as this method is public
and (I am speculating) in a public class, the cswinrt interop codegen requires unsafe code to create the glue for that list returning method to WinRT.
I would think you have a couple of options:
- not target winrt
- add <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
to your project
- change the return type, e.g. to IEnumerable<T>
As a side note, adding AllowUnsafeBlocks
to your csproj just enables use of unsafe
blocks, so it does not impact you unless you actively use them.what does your csproj look like
then yeah, it is that targetting of a specific windows version, it assumes youll be interacting with some WinRT component
the generator for which currently emits unsafe code directly into your project
but is safe to use tthat code
yes, all it requires is you have unsafe code enabled in your project so the generator can use it
you don't deal with unsafe at all
so if I will make a nugget package in the future this is safe to use>
yes
how do I edit the tag as answed
red