Skip to content

Commit c982f45

Browse files
committed
Refactoring, Issue #17
1 parent 8bec4cf commit c982f45

28 files changed

+370
-222
lines changed

.editorconfig

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ csharp_style_var_for_built_in_types = false
8080
csharp_style_var_when_type_is_apparent = false
8181

8282
# Expression-bodied members
83-
csharp_style_expression_bodied_accessors = true
84-
csharp_style_expression_bodied_constructors = false
85-
csharp_style_expression_bodied_indexers = true
86-
csharp_style_expression_bodied_lambdas = true
87-
csharp_style_expression_bodied_local_functions = false
88-
csharp_style_expression_bodied_methods = false
89-
csharp_style_expression_bodied_operators = false
90-
csharp_style_expression_bodied_properties = true
83+
csharp_style_expression_bodied_accessors = true:silent
84+
csharp_style_expression_bodied_constructors = false:silent
85+
csharp_style_expression_bodied_indexers = true:silent
86+
csharp_style_expression_bodied_lambdas = true:silent
87+
csharp_style_expression_bodied_local_functions = false:silent
88+
csharp_style_expression_bodied_methods = false:silent
89+
csharp_style_expression_bodied_operators = false:silent
90+
csharp_style_expression_bodied_properties = true:silent
9191

9292
# Pattern matching preferences
9393
csharp_style_pattern_matching_over_as_with_null_check = true
@@ -104,26 +104,26 @@ csharp_prefer_static_local_function = true
104104
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
105105

106106
# Code-block preferences
107-
csharp_prefer_braces = true
108-
csharp_prefer_simple_using_statement = true
107+
csharp_prefer_braces = true:silent
108+
csharp_prefer_simple_using_statement = true:suggestion
109109

110110
# Expression-level preferences
111-
csharp_prefer_simple_default_expression = true
112-
csharp_style_deconstructed_variable_declaration = true
113-
csharp_style_implicit_object_creation_when_type_is_apparent = true
114-
csharp_style_inlined_variable_declaration = true
111+
csharp_prefer_simple_default_expression = true:suggestion
112+
csharp_style_deconstructed_variable_declaration = true:suggestion
113+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
114+
csharp_style_inlined_variable_declaration = true:suggestion
115115
csharp_style_pattern_local_over_anonymous_function = true
116-
csharp_style_prefer_index_operator = true
117-
csharp_style_prefer_range_operator = true
118-
csharp_style_throw_expression = true
116+
csharp_style_prefer_index_operator = true:suggestion
117+
csharp_style_prefer_range_operator = true:suggestion
118+
csharp_style_throw_expression = true:suggestion
119119
csharp_style_unused_value_assignment_preference = discard_variable
120120
csharp_style_unused_value_expression_statement_preference = discard_variable
121121

122122
# 'using' directive preferences
123-
csharp_using_directive_placement = outside_namespace
123+
csharp_using_directive_placement = outside_namespace:silent
124124

125125
# New line preferences
126-
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
126+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
127127
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
128128
csharp_style_allow_embedded_statements_on_same_line_experimental = true
129129

@@ -215,3 +215,33 @@ dotnet_naming_style.begins_with_i.required_prefix = I
215215
dotnet_naming_style.begins_with_i.required_suffix =
216216
dotnet_naming_style.begins_with_i.word_separator =
217217
dotnet_naming_style.begins_with_i.capitalization = pascal_case
218+
csharp_style_namespace_declarations = file_scoped:silent
219+
csharp_style_prefer_method_group_conversion = true:silent
220+
csharp_style_prefer_top_level_statements = true:silent
221+
csharp_style_prefer_primary_constructors = true:suggestion
222+
csharp_style_prefer_null_check_over_type_check = true:suggestion
223+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
224+
csharp_style_prefer_tuple_swap = true:suggestion
225+
csharp_style_prefer_utf8_string_literals = true:suggestion
226+
227+
[*.{cs,vb}]
228+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
229+
tab_width = 4
230+
indent_size = 4
231+
end_of_line = crlf
232+
dotnet_style_coalesce_expression = true:suggestion
233+
dotnet_style_null_propagation = true:suggestion
234+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
235+
dotnet_style_prefer_auto_properties = true:silent
236+
dotnet_style_object_initializer = true:suggestion
237+
dotnet_style_prefer_collection_expression = true:suggestion
238+
dotnet_style_collection_initializer = true:suggestion
239+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
240+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
241+
dotnet_style_prefer_conditional_expression_over_return = true:silent
242+
dotnet_style_explicit_tuple_names = true:suggestion
243+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
244+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
245+
dotnet_style_prefer_compound_assignment = true:suggestion
246+
dotnet_style_prefer_simplified_interpolation = true:suggestion
247+
dotnet_style_namespace_match_folder = true:suggestion

AutoInterfaceSample/AutoInterfaceSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

AutoInterfaceSample/Program.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,36 @@ public class Program
77
public static void Main()
88
{
99
//System.Diagnostics.Debug.WriteLine(BeaKona.Output.Debug_Person.Info);
10-
IArbitrary<int> p = new Person();
11-
int f;
12-
int g = 0;
13-
p.Method(1, out f, ref g, "t", 1, 2, 3);
10+
//IArbitrary<int> p = new Person();
11+
//int f;
12+
//int g = 0;
13+
//p.Method(1, out f, ref g, "t", 1, 2, 3);
14+
15+
IPrintableComplex p = new Person2();
16+
//p.Print();
17+
p.PrintComplex();
1418
}
1519
}
1620

21+
interface IPrintableComplex
22+
{
23+
//[Obsolete("ok")]
24+
void Print();
25+
void PrintComplex();
26+
}
27+
public class SimplePrinter
28+
{
29+
public void Print() { Console.WriteLine("OK"); }
30+
public void PrintComplex() { Console.WriteLine("OK"); }
31+
}
32+
public partial class Person2 : IPrintableComplex
33+
{
34+
[BeaKona.AutoInterface(typeof(IPrintableComplex), AllowMissingMembers = false)]
35+
private readonly SimplePrinter aspect1 = new SimplePrinter();
36+
37+
public void PrintComplex() { Console.WriteLine("Oh, K."); }
38+
}
39+
1740

1841
public class SignalPlotXYConst<TX, TY, T> where TX : struct, IComparable
1942
{

BeaKona.AutoInterfaceAttributes/AutoInterfaceAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ public AutoInterfaceAttribute(Type type)
2222
public string? TemplateLanguage { get; set; }
2323
public string? TemplateBody { get; set; }
2424
public string? TemplateFileName { get; set; }
25+
public bool AllowMissingMembers { get; set; }
2526
}

BeaKona.AutoInterfaceGenerator/AutoInterfaceRecord.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ namespace BeaKona.AutoInterfaceGenerator;
44

55
internal sealed class AutoInterfaceRecord : IMemberInfo
66
{
7-
public AutoInterfaceRecord(ISymbol member, ITypeSymbol receiverType, INamedTypeSymbol interfaceType, TemplateDefinition? template, List<PartialTemplate> templateParts, bool bySignature, bool preferCoalesce)
7+
public AutoInterfaceRecord(ISymbol member, ITypeSymbol receiverType, INamedTypeSymbol interfaceType, TemplateDefinition? template, List<PartialTemplate> templateParts, bool bySignature, bool preferCoalesce, bool allowMissingMembers)
88
{
99
this.Member = member;
1010
this.ReceiverType = receiverType;
1111
this.InterfaceType = interfaceType;
1212
this.Template = template;
13-
this.TemplateParts = templateParts?.ToArray() ?? new PartialTemplate[0];
13+
this.TemplateParts = templateParts?.ToArray() ?? [];
1414
this.BySignature = bySignature;
1515
this.PreferCoalesce = preferCoalesce;
16+
this.AllowMissingMembers = allowMissingMembers;
1617
}
1718

1819
public ISymbol Member { get; }
@@ -22,4 +23,5 @@ public AutoInterfaceRecord(ISymbol member, ITypeSymbol receiverType, INamedTypeS
2223
public PartialTemplate[] TemplateParts { get; }
2324
public bool BySignature { get; }
2425
public bool PreferCoalesce { get; }
26+
public bool AllowMissingMembers { get; }
2527
}

BeaKona.AutoInterfaceGenerator/AutoInterfaceResource.Designer.cs

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)