Closed Matthew-nop closed 12 months ago
Putting this on hold for now - investigating potentially adding a safe alternative interface to ISerializationWriter
that serialisers can call
Closing this for now. This may be used as a plan B, but we've opted to go with https://github.com/Brightspace/lms/pull/42621 to enforce pinned type safety within serialization internals.
This analyzer restricts the use of these interfaces and their implementations:
ISerializationWriter
ISerializationWriterExtensions
ISerializer
ITrySerializer
Invocation, property, and field references are only permitted in classes annotated with the
[SerializationFramework]
attributeThere is one small problem/catch to this analyzer though - implementing types may still be referenced through another safe interface. Given some safe interface
a
and a dangerous interfaced
, a serialisers
such thats : a, d
may invoke dangerous behaviour througha
. Although, I don't think this can be solved without a noticeable/significant performance hit.I built the LMS with this analyzer to roughly gauge the performance. It seems to be a bit worse than the OBSL analyser which was the basis for a lot of this code. I figure this is a because for each type
t
we sometimes checkt.AllInterfaces.Any( dangerousInterface.Contains )
in addition to thedangerousInterfaces.Contains( t )
that the OBSL analyser checksBefore merging, the annotations should be added in the LMS:
ref: https://github.com/Brightspace/lms-dotnet-migration-issues/issues/135