-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent external codecs from serializing types which are abstract, ge…
…nerated, or from the framework itself (#8765)
- Loading branch information
1 parent
eca20f5
commit d6894ae
Showing
11 changed files
with
312 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Orleans.Serialization.Abstractions/FrameworkPartAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace Orleans.Metadata; | ||
|
||
/// <summary> | ||
/// Specifies that an assembly does not contain application code. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly)] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public sealed class FrameworkPartAttribute : Attribute | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.CodeDom.Compiler; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
using Orleans.Metadata; | ||
|
||
namespace Orleans.Serialization.Codecs; | ||
|
||
/// <summary> | ||
/// Defines common type filtering operations. | ||
/// </summary> | ||
public class CommonCodecTypeFilter | ||
{ | ||
/// <summary> | ||
/// Returns true if the provided type is a framework or abstract type. | ||
/// </summary> | ||
/// <param name="type">The type to check.</param> | ||
/// <returns><see langword="true"/> if the type is a framework or abstract type, otherwise <see langword="false"/>.</returns> | ||
public static bool IsAbstractOrFrameworkType(Type type) | ||
{ | ||
if (type.IsAbstract | ||
|| type.GetCustomAttributes<GeneratedCodeAttribute>().Any(a => a.Tool.Equals("OrleansCodeGen")) | ||
|| type.Assembly.GetCustomAttribute<FrameworkPartAttribute>() is not null) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.