Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving pinning attributes and the pinned analyzer #921

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace D2L.CodeStyle.Annotations.Pinning {
/// <summary>
/// Represents a parameter in the call chain of serialization in order to enforce pinning or otherwise set limitations on serialized types
/// </summary>
[AttributeUsage( AttributeTargets.Parameter | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false )]
public sealed class MustBeDeserializableAttribute : Attribute {
}
}
10 changes: 10 additions & 0 deletions src/D2L.CodeStyle.Annotations/Pinning/MustBePinnedAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace D2L.CodeStyle.Annotations.Pinning {
/// <summary>
/// Represents a parameter in a dangerous call chain (e.g. serialization using the assembly qualified name) that must be pinned
/// </summary>
[AttributeUsage( AttributeTargets.Parameter | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false )]
public sealed class MustBePinnedAttribute : Attribute {
}
}
22 changes: 22 additions & 0 deletions src/D2L.CodeStyle.Annotations/Pinning/PinnedAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace D2L.CodeStyle.Annotations.Pinning {
/// <summary>
/// The type should not be moved from its assembly due to risk of deserialization based on assembly qualified name or other dangerous call chains
/// </summary>
[AttributeUsage( AttributeTargets.Class
| AttributeTargets.Struct
| AttributeTargets.Interface
, AllowMultiple = false, Inherited = false )]
public sealed class PinnedAttribute : Attribute {
public string FullyQualifiedName { get; }
public string Assembly { get; }
public bool PinnedRecursively { get; }

public PinnedAttribute( string fullyQualifiedName, string assembly, bool pinnedRecursively = false ) {
FullyQualifiedName = fullyQualifiedName;
Assembly = assembly;
PinnedRecursively = pinnedRecursively;
}
}
}
Loading