Skip to content

Commit badeadb

Browse files
committed
Suppress two instances of SYSLIB0050 ("Formatter-based serialization is obsolete")
1 parent efe234c commit badeadb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Castle.Core/DynamicProxy/Generators/Emitters/ClassEmitter.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ internal sealed class ClassEmitter
4343

4444
private GenericTypeParameterBuilder[] genericTypeParams;
4545

46+
// TODO: reconsider the following warning suppression once we have made a decision
47+
// regarding DynamicProxy's future support for serialization. For now, we tolerate
48+
// the `[Serializable]` attribute on types a little longer, because it is not just
49+
// for `BinaryFormatter`'s sake, but also for e.g. the non-obsolete `DataContract-
50+
// erializer` which recognizes it.
51+
#pragma warning disable SYSLIB0050
4652
internal const TypeAttributes DefaultTypeAttributes =
4753
TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Serializable;
54+
#pragma warning restore SYSLIB0050
4855

4956
public ClassEmitter(TypeBuilder typeBuilder)
5057
{
@@ -195,7 +202,10 @@ public FieldReference CreateField(string name, Type fieldType, bool serializable
195202

196203
if (!serializable)
197204
{
205+
// TODO: as above, see explanation there (at `DefaultTypeAttributes`'s declaration site)
206+
#pragma warning disable SYSLIB0050
198207
atts |= FieldAttributes.NotSerialized;
208+
#pragma warning restore CS0001
199209
}
200210

201211
return CreateField(name, fieldType, atts);

0 commit comments

Comments
 (0)