Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ElanHasson committed Aug 17, 2022
1 parent 684d71f commit 941553f
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 56 deletions.
125 changes: 82 additions & 43 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version: 4.1.1 (Using https://semver.org/)
# Updated: 2022-05-23
# Version: 4.0.0 (Using https://semver.org/)
# Updated: 2021-10-12
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
Expand All @@ -18,33 +18,6 @@ indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
csharp_using_directive_placement = inside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:warning
csharp_style_namespace_declarations = file_scoped:error
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
csharp_style_expression_bodied_operators = true:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
csharp_style_expression_bodied_lambdas = true:warning
csharp_style_expression_bodied_local_functions = true:warning
csharp_style_throw_expression = true:warning
csharp_style_prefer_null_check_over_type_check = true:warning
csharp_prefer_simple_default_expression = true:warning
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_inlined_variable_declaration = true:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
csharp_indent_labels = no_change
csharp_space_around_binary_operators = before_and_after

##########################################
# File Extension Settings
Expand All @@ -71,11 +44,11 @@ indent_size = 2
indent_size = 2

# Markdown Files
[*.{md,mdx}]
[*.md]
trim_trailing_whitespace = false

# Web Files
[*.{htm,html,js,jsm,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}]
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}]
indent_size = 2

# Batch Files
Expand Down Expand Up @@ -144,12 +117,17 @@ dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
# File header preferences
# file_header_template = <copyright file="{fileName}" company="PROJECT-AUTHOR">\n© PROJECT-AUTHOR\n</copyright>
# file_header_template = <copyright file="{fileName}" company="Serverless BU">\n© Serverless BU\n</copyright>
# If you use StyleCop, you'll need to disable SA1636: File header copyright text should match.
# dotnet_diagnostic.SA1636.severity = none
dotnet_diagnostic.SA1636.severity = none
# Undocumented
dotnet_style_operator_placement_when_wrapping = end_of_line
csharp_style_prefer_null_check_over_type_check = true:warning
dotnet_style_namespace_match_folder = true:suggestion
dotnet_diagnostic.IDE0130.severity = suggestion
dotnet_diagnostic.VSTHRD200.severity = none
dotnet_diagnostics.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods
dotnet_analyzer_diagnostic.VSTHRD200.severity = none # VSTHRD200: Use "Async" suffix for async methods

# C# Style Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
Expand Down Expand Up @@ -192,6 +170,10 @@ dotnet_diagnostic.IDE0063.severity = suggestion
csharp_using_directive_placement = inside_namespace:warning
# Modifier preferences
csharp_prefer_static_local_function = true:warning
# Undocumented
csharp_style_namespace_declarations = file_scoped:warning
# VSTHRD111: Use ConfigureAwait(bool)
dotnet_diagnostic.VSTHRD111.severity = none

##########################################
# Unnecessary Code Rules
Expand Down Expand Up @@ -221,15 +203,12 @@ dotnet_diagnostic.IDE0059.severity = suggestion
# Organize using directives
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
# Dotnet namespace options
dotnet_style_namespace_match_folder = true:suggestion
dotnet_diagnostic.IDE0130.severity = suggestion

# C# formatting rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
[*.{cs,csx,cake}]
# Newline options
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#new-line-options
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
Expand All @@ -238,15 +217,15 @@ csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation options
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#indentation-options
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = no_change
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false
# Spacing options
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#spacing-options
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = false
Expand All @@ -270,12 +249,9 @@ csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
# Wrap options
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
# Namespace options
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#namespace-options
csharp_style_namespace_declarations = file_scoped:error

##########################################
# .NET Naming Rules
Expand Down Expand Up @@ -440,9 +416,72 @@ dotnet_naming_symbols.parameters_group.applicable_kinds = parameter
dotnet_naming_rule.parameters_rule.symbols = parameters_group
dotnet_naming_rule.parameters_rule.style = camel_case_style
dotnet_naming_rule.parameters_rule.severity = warning

##########################################
# StyleCop
##########################################

[*]
# SA0001: XML comment analysis is disabled due to project configuration
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA0001.md
dotnet_diagnostic.SA0001.severity = none
tab_width = 4
end_of_line = crlf

[*.cs]
# SA1515: Single-line comment should be preceded by blank line.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md
dotnet_diagnostic.SA1515.severity = none

# SA1600: A C# code element is missing a documentation header.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md
dotnet_diagnostic.SA1600.severity = none

# SA1601: A C# partial element is missing a documentation header.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1601.md
dotnet_diagnostic.SA1601.severity = none

# SA1602: An item within a C# enumeration is missing an XML documentation header.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1602.md
dotnet_diagnostic.SA1602.severity = none

# SA1633: A C# code file is missing a standard file header.
# Justification: Comments turned off
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md
dotnet_diagnostic.SA1633.severity = none
csharp_using_directive_placement = inside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:warning
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
csharp_style_expression_bodied_operators = true:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
csharp_style_expression_bodied_lambdas = true:warning
csharp_style_expression_bodied_local_functions = true:warning
csharp_style_throw_expression = true:warning
csharp_style_prefer_null_check_over_type_check = true:warning
csharp_prefer_simple_default_expression = true:warning
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_inlined_variable_declaration = true:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
csharp_indent_labels = no_change
csharp_space_around_binary_operators = before_and_after

##########################################
# License
##########################################
Expand Down
5 changes: 4 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all" Version="17.3.44" />
<PackageReference Include="MinVer" PrivateAssets="all" Version="4.1.0" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" Version="1.2.0-beta.435" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.3.0-3.final">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion Orleans.StorageProviderInterceptors.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
dotnet-tools.json = dotnet-tools.json
global.json = global.json
Key.snk = Key.snk
stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{7EDFA103-DB69-4C88-9DE4-97ADBF8253A1}"
Expand Down Expand Up @@ -69,6 +68,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.StorageProviderInte
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.StorageProviderInterceptors", "Source\Orleans.StorageProviderInterceptors\Orleans.StorageProviderInterceptors.csproj", "{B3B4B0E9-9012-4EED-B3B1-95892F19DC44}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Source\Sample\Sample.csproj", "{69D2C306-D1AF-446D-9DA5-B9D7DB348413}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -83,6 +84,10 @@ Global
{B3B4B0E9-9012-4EED-B3B1-95892F19DC44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3B4B0E9-9012-4EED-B3B1-95892F19DC44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3B4B0E9-9012-4EED-B3B1-95892F19DC44}.Release|Any CPU.Build.0 = Release|Any CPU
{69D2C306-D1AF-446D-9DA5-B9D7DB348413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69D2C306-D1AF-446D-9DA5-B9D7DB348413}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69D2C306-D1AF-446D-9DA5-B9D7DB348413}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69D2C306-D1AF-446D-9DA5-B9D7DB348413}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -94,6 +99,7 @@ Global
{841C67EF-BBB2-4730-8E29-22FF3FD54306} = {EFE1E5ED-D337-4874-82EC-D9FA0BC7D3AB}
{18C56725-2604-4BA5-89F3-40B2DC2DD81F} = {E1B24F25-B8A4-46EE-B7EB-7803DCFC543F}
{B3B4B0E9-9012-4EED-B3B1-95892F19DC44} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
{69D2C306-D1AF-446D-9DA5-B9D7DB348413} = {719809C2-A551-4C4A-9EFD-B10FB5E35BC0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {73F36209-F8D6-4066-8951-D97729F773CF}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
namespace Orleans.StorageProviderInterceptors;

using System.Threading.Tasks;
using Orleans;
using Orleans.Runtime;
using Orleans.Storage;

/// <summary>
/// GrainStorageInterceptorProxy is responsable for performing the interception of the given storage provider.
/// </summary>
public class GrainStorageInterceptorProxy : IGrainStorage, ILifecycleParticipant<ISiloLifecycle>
{
private readonly IServiceProvider serviceProvider;

/// <summary>
/// Creates an instance of GrainStorageInterceptorProxy.
/// </summary>
/// <param name="serviceProvider">a service provider.</param>
public GrainStorageInterceptorProxy(IServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider;
this.targetProvider = serviceProvider.Storage
}

/// <summary>Delete / Clear data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">Copy of last-known state data object for this grain.</param>
/// <returns>Completion promise for the Delete operation on the specified grain.</returns>
public Task ClearStateAsync(string grainType, GrainReference grainReference, IGrainState grainState)
{

}

/// <summary>
/// Provides hook to take part in lifecycle.
/// Also may act as a signal interface indicating that an object can take part in lifecycle.
/// </summary>
/// <param name="lifecycle">The lifecycle event.</param>
public void Participate(ISiloLifecycle lifecycle) => throw new NotImplementedException();

/// <summary>Read data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">State data object to be populated for this grain.</param>
/// <returns>Completion promise for the Read operation on the specified grain.</returns>
public Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) => throw new NotImplementedException();

/// <summary>Write data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">State data object to be written for this grain.</param>
/// <returns>Completion promise for the Write operation on the specified grain.</returns>
public Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace Orleans.StorageProviderInterceptors;

using System.Threading.Tasks;
using Orleans;
using Orleans.Runtime;

/// <summary>
/// IGrainStorageInterceptor defines an interceptor.
/// </summary>
public interface IGrainStorageInterceptor
{
/// <summary>Called before the Delete / Clear data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">Copy of last-known state data object for this grain.</param>
/// <returns>Completion promise for the Delete operation on the specified grain.</returns>
ValueTask OnBeforeClearStateAsync(string grainType, GrainReference grainReference, IGrainState grainState);

/// <summary>Called after the Delete / Clear data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">Copy of last-known state data object for this grain.</param>
/// <returns>Completion promise for the Delete operation on the specified grain.</returns>
ValueTask OnAfterClearStateAsync(string grainType, GrainReference grainReference, IGrainState grainState);

/// <summary>Called before the Read data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">State data object to be populated for this grain.</param>
/// <returns>Completion promise for the Read operation on the specified grain.</returns>
public ValueTask OnBeforeReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState);

/// <summary>Called after the Read data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">State data object to be populated for this grain.</param>
/// <returns>Completion promise for the Read operation on the specified grain.</returns>
public ValueTask OnAfterReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState);

/// <summary>Called before the Write data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">State data object to be written for this grain.</param>
/// <returns>Completion promise for the Write operation on the specified grain.</returns>
public ValueTask OnBeforeWriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState);

/// <summary>Called after the Write data function for this storage instance.</summary>
/// <param name="grainType">Type of this grain [fully qualified class name].</param>
/// <param name="grainReference">Grain reference object for this grain.</param>
/// <param name="grainState">State data object to be written for this grain.</param>
/// <returns>Completion promise for the Write operation on the specified grain.</returns>
public ValueTask OnAfterWriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -11,11 +11,7 @@
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Runtime.Abstractions" Version="3.6.3" />
<PackageReference Include="Microsoft.Orleans.Runtime.Abstractions" Version="3.6.5" />
</ItemGroup>

</Project>
Loading

0 comments on commit 941553f

Please sign in to comment.