Add .editorconfig and StyleCop rules, cleanup project files (#250)

This commit is contained in:
Pavel Krymets 2019-11-22 12:50:02 -08:00 коммит произвёл GitHub
Родитель a52ca2adfe
Коммит 3f994ab4fb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
80 изменённых файлов: 1016 добавлений и 282 удалений

185
.editorconfig Normal file
Просмотреть файл

@ -0,0 +1,185 @@
# editorconfig.org
# top-most EditorConfig file
root = true
# Default settings:
# A newline ending every file
# Use 4 spaces as indentation
[**]
insert_final_newline = true
indent_style = space
indent_size = 4
# C# files
[**.cs]
# New line preferences
csharp_new_line_before_open_brace = all # vs-default: any
csharp_new_line_before_else = true # vs-default: true
csharp_new_line_before_catch = true # vs-default: true
csharp_new_line_before_finally = true # vs-default: true
csharp_new_line_before_members_in_object_initializers = true # vs-default: true
csharp_new_line_before_members_in_anonymous_types = true # vs-default: true
csharp_new_line_between_query_expression_clauses = true # vs-default: true
# Indentation preferences
csharp_indent_block_contents = true # vs-default: true
csharp_indent_braces = false # vs-default: false
csharp_indent_case_contents = true # vs-default: true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true # vs-default: true
csharp_indent_labels = one_less_than_current # vs-default: one_less_than_current
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion # vs-default: false:none
dotnet_style_qualification_for_property = false:suggestion # vs-default: false:none
dotnet_style_qualification_for_method = false:suggestion # vs-default: false:none
dotnet_style_qualification_for_event = false:suggestion # vs-default: false:none
# only use var when it's obvious what the variable type is
csharp_style_var_for_built_in_types = false:none # vs-default: true:none
csharp_style_var_when_type_is_apparent = false:none # vs-default: true:none
csharp_style_var_elsewhere = false:suggestion # vs-default: true:none
# use language keywords instead of BCL types
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion # vs-default: true:none
dotnet_style_predefined_type_for_member_access = true:suggestion # vs-default: true:none
# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case
# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
# Code style defaults
csharp_using_directive_placement = outside_namespace:suggestion
dotnet_sort_system_directives_first = true # vs-default: true
csharp_prefer_braces = true:refactoring
csharp_preserve_single_line_blocks = true # vs-default: true
csharp_preserve_single_line_statements = false # vs-default: true
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_simple_using_statement = false:none
csharp_style_prefer_switch_expression = true:suggestion
# Code quality
dotnet_style_readonly_field = true:suggestion
dotnet_code_quality_unused_parameters = non_public:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion # vs-default: true:suggestion
dotnet_style_collection_initializer = true:suggestion # vs-default: true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion # vs-default: true:suggestion
dotnet_style_coalesce_expression = true:suggestion # vs-default: true:suggestion
dotnet_style_null_propagation = true:suggestion # vs-default: true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:refactoring
dotnet_style_prefer_conditional_expression_over_return = true:refactoring
csharp_prefer_simple_default_expression = true:suggestion
# Expression-bodied members
csharp_style_expression_bodied_methods = false:none # vs-default: false:none
csharp_style_expression_bodied_constructors = false:none # vs-default: false:none
csharp_style_expression_bodied_operators = false:none # vs-default: false:none
csharp_style_expression_bodied_properties = true:none # vs-default: true:none
csharp_style_expression_bodied_indexers = true:none # vs-default: true:none
csharp_style_expression_bodied_accessors = true:none # vs-default: true:none
csharp_style_expression_bodied_lambdas = true:refactoring
csharp_style_expression_bodied_local_functions = true:refactoring
# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion # vs-default: true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion # vs-default: true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion # vs-default: true:suggestion
# Null checking preferences
csharp_style_throw_expression = true:suggestion # vs-default: true:suggestion
csharp_style_conditional_delegate_call = true:suggestion # vs-default: true:suggestion
# Other features
csharp_style_prefer_index_operator = false:none
csharp_style_prefer_range_operator = false:none
csharp_style_pattern_local_over_anonymous_function = false:none
# Space preferences
csharp_space_after_cast = false # vs-default: false
csharp_space_after_colon_in_inheritance_clause = true # vs-default: true
csharp_space_after_comma = true # vs-default: true
csharp_space_after_dot = false # vs-default: false
csharp_space_after_keywords_in_control_flow_statements = true # vs-default: true
csharp_space_after_semicolon_in_for_statement = true # vs-default: true
csharp_space_around_binary_operators = before_and_after # vs-default: before_and_after
csharp_space_around_declaration_statements = do_not_ignore # vs-default: false
csharp_space_before_colon_in_inheritance_clause = true # vs-default: true
csharp_space_before_comma = false # vs-default: false
csharp_space_before_dot = false # vs-default: false
csharp_space_before_open_square_brackets = false # vs-default: false
csharp_space_before_semicolon_in_for_statement = false # vs-default: false
csharp_space_between_empty_square_brackets = false # vs-default: false
csharp_space_between_method_call_empty_parameter_list_parentheses = false # vs-default: false
csharp_space_between_method_call_name_and_opening_parenthesis = false # vs-default: false
csharp_space_between_method_call_parameter_list_parentheses = false # vs-default: false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false # vs-default: false
csharp_space_between_method_declaration_name_and_open_parenthesis = false # vs-default: false
csharp_space_between_method_declaration_parameter_list_parentheses = false # vs-default: false
csharp_space_between_parentheses = false # vs-default: false
csharp_space_between_square_brackets = false # vs-default: false
# Require accessibility modifiers
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion # vs-default: for_non_interface_members:none
# Analyzers
dotnet_code_quality.ca1802.api_surface = private, internal
# Xml project files
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2
# Xml build files
[*.builds]
indent_size = 2
# Xml files
[*.{xml,stylecop,resx,ruleset}]
indent_size = 2
# Xml config files
[*.{props,targets,config,nuspec}]
indent_size = 2
# Shell scripts
[*.sh]
end_of_line = lf
[*.{cmd, bat}]
end_of_line = crlf

Просмотреть файл

@ -7,7 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRest.CSharp.V3", "src\A
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRest.CodeModel", "src\AutoRest.CodeModel\AutoRest.CodeModel.csproj", "{FD9339E6-A987-4506-977F-C294A31D0D53}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRest.CodeModel", "src\AutoRest.CodeModel\AutoRest.CodeModel.csproj", "{FD9339E6-A987-4506-977F-C294A31D0D53}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRest.TestServer.Tests", "test\AutoRest.TestServer.Tests\AutoRest.TestServer.Tests.csproj", "{C0EC4E09-EB17-4C6B-AB31-F14E5C834D7D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRest.TestServer.Tests", "test\AutoRest.TestServer.Tests\AutoRest.TestServer.Tests.csproj", "{C0EC4E09-EB17-4C6B-AB31-F14E5C834D7D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{37E859E7-8CCE-426B-8232-35B2C1503230}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRest.CoreShared", "src\AutoRest.CoreShared\AutoRest.CoreShared.csproj", "{9DB44A43-CFD6-4868-844F-70A25834AE3D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRest.CoreShared", "src\AutoRest.CoreShared\AutoRest.CoreShared.csproj", "{9DB44A43-CFD6-4868-844F-70A25834AE3D}"
EndProject EndProject
Global Global

46
Directory.Build.props Normal file
Просмотреть файл

@ -0,0 +1,46 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<RepoEngPath>$(MSBuildThisFileDirectory)eng</RepoEngPath>
<RepoSrcPath>$(RepoRoot)src</RepoSrcPath>
<IsTestProject Condition="$(MSBuildProjectName.EndsWith('.Tests'))">true</IsTestProject>
</PropertyGroup>
<!-- Setup default project properties -->
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
<PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
</PropertyGroup>
<!-- Setup common output paths -->
<PropertyGroup>
<ArtifactsDir Condition="'$(ArtifactsDir)' == ''">$(RepoRoot)artifacts\</ArtifactsDir>
<ArtifactsObjDir>$(ArtifactsDir)obj\</ArtifactsObjDir>
<ArtifactsBinDir>$(ArtifactsDir)bin\</ArtifactsBinDir>
<ArtifactsPackagesDir>$(ArtifactsDir)packages\$(Configuration)\</ArtifactsPackagesDir>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<OutDirName Condition="'$(OutDirName)' == ''">$(MSBuildProjectName)</OutDirName>
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)$(OutDirName)\'))</BaseOutputPath>
<OutputPath Condition="'$(PlatformName)' == 'AnyCPU'">$(BaseOutputPath)$(Configuration)\</OutputPath>
<OutputPath Condition="'$(PlatformName)' != 'AnyCPU'">$(BaseOutputPath)$(PlatformName)\$(Configuration)\</OutputPath>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$([System.IO.Path]::GetFullPath('$(ArtifactsObjDir)$(OutDirName)\'))</BaseIntermediateOutputPath>
<IntermediateOutputPath Condition="'$(PlatformName)' == 'AnyCPU'">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
<PackageOutputPath>$(ArtifactsPackagesDir)</PackageOutputPath>
<CodeAnalysisRuleSet>$(RepoEngPath)\CodeAnalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)AzureSDKClient.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<PublicSign>false</PublicSign>
<ImportDefaultReferences>false</ImportDefaultReferences>
<LangVersion>preview</LangVersion>
</PropertyGroup>
</Project>

11
Directory.Build.targets Normal file
Просмотреть файл

@ -0,0 +1,11 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<AdditionalFiles Include="$(RepoEngPath)\stylecop.json">
<Visible>false</Visible>
</AdditionalFiles>
</ItemGroup>
</Project>

217
eng/CodeAnalysis.ruleset Normal file
Просмотреть файл

@ -0,0 +1,217 @@
<?xml version="1.0"?>
<RuleSet Name="StyleCop.Analyzers rules with selected rules set to warning." Description="StyleCop.Analyzers with selected rules enabled. Rules with IsEnabledByDefault = false are disabled." ToolsVersion="14.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.SpecialRules">
<Rule Id="SA0001" Action="None" /> <!-- XML comment analysis disabled -->
<Rule Id="SA0002" Action="None" /> <!-- Invalid settings file -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.SpacingRules">
<Rule Id="SA1000" Action="Warning" /> <!-- Keywords should be spaced correctly -->
<Rule Id="SA1001" Action="None" /> <!-- Commas should be spaced correctly -->
<Rule Id="SA1002" Action="None" /> <!-- Semicolons should be spaced correctly -->
<Rule Id="SA1003" Action="None" /> <!-- Symbols should be spaced correctly -->
<Rule Id="SA1004" Action="None" /> <!-- Documentation lines should begin with single space -->
<Rule Id="SA1005" Action="None" /> <!-- Single line comments should begin with single space -->
<Rule Id="SA1006" Action="None" /> <!-- Preprocessor keywords should not be preceded by space -->
<Rule Id="SA1007" Action="None" /> <!-- Operator keyword should be followed by space -->
<Rule Id="SA1008" Action="None" /> <!-- Opening parenthesis should be spaced correctly -->
<Rule Id="SA1009" Action="None" /> <!-- Closing parenthesis should be spaced correctly -->
<Rule Id="SA1010" Action="None" /> <!-- Opening square brackets should be spaced correctly -->
<Rule Id="SA1011" Action="None" /> <!-- Closing square brackets should be spaced correctly -->
<Rule Id="SA1012" Action="None" /> <!-- Opening braces should be spaced correctly -->
<Rule Id="SA1013" Action="None" /> <!-- Closing braces should be spaced correctly -->
<Rule Id="SA1014" Action="None" /> <!-- Opening generic brackets should be spaced correctly -->
<Rule Id="SA1015" Action="None" /> <!-- Closing generic brackets should be spaced correctly -->
<Rule Id="SA1016" Action="None" /> <!-- Opening attribute brackets should be spaced correctly -->
<Rule Id="SA1017" Action="None" /> <!-- Closing attribute brackets should be spaced correctly -->
<Rule Id="SA1018" Action="None" /> <!-- Nullable type symbols should be spaced correctly -->
<Rule Id="SA1019" Action="Warning" /> <!-- Member access symbols should be spaced correctly -->
<Rule Id="SA1020" Action="Warning" /> <!-- Increment decrement symbols should be spaced correctly -->
<Rule Id="SA1021" Action="None" /> <!-- Negative signs should be spaced correctly -->
<Rule Id="SA1022" Action="None" /> <!-- Positive signs should be spaced correctly -->
<Rule Id="SA1023" Action="None" /> <!-- Dereference and access of symbols should be spaced correctly -->
<Rule Id="SA1024" Action="None" /> <!-- Colons should be spaced correctly -->
<Rule Id="SA1025" Action="None" /> <!-- Code should not contain multiple whitespace in a row -->
<Rule Id="SA1026" Action="Warning" /> <!-- Code should not contain space after new or stackalloc keyword in implicitly typed array allocation -->
<Rule Id="SA1027" Action="None" /> <!-- Use tabs correctly -->
<Rule Id="SA1028" Action="Warning" /> <!-- Code should not contain trailing whitespace -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.ReadabilityRules">
<Rule Id="SA1100" Action="None" /> <!-- Do not prefix calls with base unless local implementation exists -->
<Rule Id="SA1101" Action="None" /> <!-- Prefix local calls with this -->
<Rule Id="SA1102" Action="None" /> <!-- Query clause should follow previous clause -->
<Rule Id="SA1103" Action="None" /> <!-- Query clauses should be on separate lines or all on one line -->
<Rule Id="SA1104" Action="None" /> <!-- Query clause should begin on new line when previous clause spans multiple lines -->
<Rule Id="SA1105" Action="None" /> <!-- Query clauses spanning multiple lines should begin on own line -->
<Rule Id="SA1106" Action="None" /> <!-- Code should not contain empty statements -->
<Rule Id="SA1107" Action="None" /> <!-- Code should not contain multiple statements on one line -->
<Rule Id="SA1108" Action="None" /> <!-- Block statements should not contain embedded comments -->
<Rule Id="SA1109" Action="None" /> <!-- Block statements should not contain embedded regions -->
<Rule Id="SA1110" Action="None" /> <!-- Opening parenthesis or bracket should be on declaration line -->
<Rule Id="SA1111" Action="None" /> <!-- Closing parenthesis should be on line of last parameter -->
<Rule Id="SA1112" Action="None" /> <!-- Closing parenthesis should be on line of opening parenthesis -->
<Rule Id="SA1113" Action="None" /> <!-- Comma should be on the same line as previous parameter -->
<Rule Id="SA1114" Action="None" /> <!-- Parameter list should follow declaration -->
<Rule Id="SA1115" Action="None" /> <!-- Parameter should follow comma -->
<Rule Id="SA1116" Action="None" /> <!-- Split parameters should start on line after declaration -->
<Rule Id="SA1117" Action="None" /> <!-- Parameters should be on same line or separate lines -->
<Rule Id="SA1118" Action="None" /> <!-- Parameter should not span multiple lines -->
<Rule Id="SA1120" Action="None" /> <!-- Comments should contain text -->
<Rule Id="SA1121" Action="None" /> <!-- Use built-in type alias -->
<Rule Id="SA1122" Action="None" /> <!-- Use string.Empty for empty strings -->
<Rule Id="SA1123" Action="None" /> <!-- Do not place regions within elements -->
<Rule Id="SA1124" Action="None" /> <!-- Do not use regions -->
<Rule Id="SA1125" Action="None" /> <!-- Use shorthand for nullable types -->
<Rule Id="SA1126" Action="None" /> <!-- Prefix calls correctly -->
<Rule Id="SA1127" Action="None" /> <!-- Generic type constraints should be on their own line -->
<Rule Id="SA1128" Action="None" /> <!-- Put constructor initializers on their own line -->
<Rule Id="SA1129" Action="None" /> <!-- Do not use default value type constructor -->
<Rule Id="SA1130" Action="None" /> <!-- Use lambda syntax -->
<Rule Id="SA1131" Action="None" /> <!-- Use readable conditions -->
<Rule Id="SA1132" Action="None" /> <!-- Do not combine fields -->
<Rule Id="SA1133" Action="None" /> <!-- Do not combine attributes -->
<Rule Id="SA1134" Action="None" /> <!-- Attributes should not share line -->
<Rule Id="SA1135" Action="None" /> <!-- Using directives should be qualified -->
<Rule Id="SA1136" Action="None" /> <!-- Enum values should be on separate lines -->
<Rule Id="SA1137" Action="None" /> <!-- Elements should have the same indentation -->
<Rule Id="SA1139" Action="None" /> <!-- Use literal suffix notation instead of casting -->
<Rule Id="SX1101" Action="None" /> <!-- Do not prefix local calls with 'this.' -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.OrderingRules">
<Rule Id="SA1200" Action="None" /> <!-- Using directives should be placed correctly -->
<Rule Id="SA1201" Action="None" /> <!-- Elements should appear in the correct order -->
<Rule Id="SA1202" Action="None" /> <!-- Elements should be ordered by access -->
<Rule Id="SA1203" Action="None" /> <!-- Constants should appear before fields -->
<Rule Id="SA1204" Action="None" /> <!-- Static elements should appear before instance elements -->
<Rule Id="SA1205" Action="None" /> <!-- Partial elements should declare access -->
<Rule Id="SA1206" Action="None" /> <!-- Declaration keywords should follow order -->
<Rule Id="SA1207" Action="None" /> <!-- Protected should come before internal -->
<Rule Id="SA1208" Action="None" /> <!-- System using directives should be placed before other using directives -->
<Rule Id="SA1209" Action="None" /> <!-- Using alias directives should be placed after other using directives -->
<Rule Id="SA1210" Action="None" /> <!-- Using directives should be ordered alphabetically by namespace -->
<Rule Id="SA1211" Action="None" /> <!-- Using alias directives should be ordered alphabetically by alias name -->
<Rule Id="SA1212" Action="None" /> <!-- Property accessors should follow order -->
<Rule Id="SA1213" Action="None" /> <!-- Event accessors should follow order -->
<Rule Id="SA1214" Action="None" /> <!-- Readonly fields should appear before non-readonly fields -->
<Rule Id="SA1216" Action="None" /> <!-- Using static directives should be placed at the correct location -->
<Rule Id="SA1217" Action="None" /> <!-- Using static directives should be ordered alphabetically -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.NamingRules">
<Rule Id="SA1300" Action="None" /> <!-- Element should begin with upper-case letter -->
<Rule Id="SA1301" Action="None" /> <!-- Element should begin with lower-case letter -->
<Rule Id="SA1302" Action="Warning" /> <!-- Interface names should begin with I -->
<Rule Id="SA1303" Action="None" /> <!-- Const field names should begin with upper-case letter -->
<Rule Id="SA1304" Action="None" /> <!-- Non-private readonly fields should begin with upper-case letter -->
<Rule Id="SA1305" Action="None" /> <!-- Field names should not use Hungarian notation -->
<Rule Id="SA1306" Action="None" /> <!-- Field names should begin with lower-case letter -->
<Rule Id="SA1307" Action="None" /> <!-- Accessible fields should begin with upper-case letter -->
<Rule Id="SA1308" Action="None" /> <!-- Variable names should not be prefixed -->
<Rule Id="SA1309" Action="None" /> <!-- Field names should not begin with underscore -->
<Rule Id="SA1310" Action="None" /> <!-- Field names should not contain underscore -->
<Rule Id="SA1311" Action="None" /> <!-- Static readonly fields should begin with upper-case letter -->
<Rule Id="SA1312" Action="None" /> <!-- Variable names should begin with lower-case letter -->
<Rule Id="SA1313" Action="None" /> <!-- Parameter names should begin with lower-case letter -->
<Rule Id="SA1314" Action="None" /> <!-- Type parameter names should begin with T -->
<Rule Id="SX1309" Action="None" /> <!-- Field names should begin with underscore -->
<Rule Id="SX1309S" Action="None" /> <!-- Static field names should begin with underscore -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.MaintainabilityRules">
<Rule Id="SA1119" Action="None" /> <!-- Statement should not use unnecessary parenthesis -->
<Rule Id="SA1400" Action="Warning" /> <!-- Access modifier should be declared -->
<Rule Id="SA1401" Action="None" /> <!-- Fields should be private -->
<Rule Id="SA1402" Action="Warning" /> <!-- File may only contain a single type -->
<Rule Id="SA1403" Action="None" /> <!-- File may only contain a single namespace -->
<Rule Id="SA1404" Action="None" /> <!-- Code analysis suppression should have justification -->
<Rule Id="SA1405" Action="None" /> <!-- Debug.Assert should provide message text -->
<Rule Id="SA1406" Action="None" /> <!-- Debug.Fail should provide message text -->
<Rule Id="SA1407" Action="None" /> <!-- Arithmetic expressions should declare precedence -->
<Rule Id="SA1408" Action="None" /> <!-- Conditional expressions should declare precedence -->
<Rule Id="SA1409" Action="None" /> <!-- Remove unnecessary code -->
<Rule Id="SA1410" Action="None" /> <!-- Remove delegate parenthesis when possible -->
<Rule Id="SA1411" Action="Warning" /> <!-- Attribute constructor should not use unnecessary parenthesis -->
<Rule Id="SA1412" Action="None" /> <!-- Store files as UTF-8 with byte order mark -->
<Rule Id="SA1413" Action="None" /> <!-- Use trailing comma in multi-line initializers -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.LayoutRules">
<Rule Id="SA1500" Action="None" /> <!-- Braces for multi-line statements should not share line -->
<Rule Id="SA1501" Action="None" /> <!-- Statement should not be on a single line -->
<Rule Id="SA1502" Action="None" /> <!-- Element should not be on a single line -->
<Rule Id="SA1503" Action="None" /> <!-- Braces should not be omitted -->
<Rule Id="SA1504" Action="None" /> <!-- All accessors should be single-line or multi-line -->
<Rule Id="SA1505" Action="None" /> <!-- Opening braces should not be followed by blank line -->
<Rule Id="SA1506" Action="None" /> <!-- Element documentation headers should not be followed by blank line -->
<Rule Id="SA1507" Action="None" /> <!-- Code should not contain multiple blank lines in a row -->
<Rule Id="SA1508" Action="None" /> <!-- Closing braces should not be preceded by blank line -->
<Rule Id="SA1509" Action="None" /> <!-- Opening braces should not be preceded by blank line -->
<Rule Id="SA1510" Action="None" /> <!-- Chained statement blocks should not be preceded by blank line -->
<Rule Id="SA1511" Action="None" /> <!-- While-do footer should not be preceded by blank line -->
<Rule Id="SA1512" Action="None" /> <!-- Single-line comments should not be followed by blank line -->
<Rule Id="SA1513" Action="None" /> <!-- Closing brace should be followed by blank line -->
<Rule Id="SA1514" Action="None" /> <!-- Element documentation header should be preceded by blank line -->
<Rule Id="SA1515" Action="None" /> <!-- Single-line comment should be preceded by blank line -->
<Rule Id="SA1516" Action="None" /> <!-- Elements should be separated by blank line -->
<Rule Id="SA1517" Action="Warning" /> <!-- Code should not contain blank lines at start of file -->
<Rule Id="SA1518" Action="Warning" /> <!-- Use line endings correctly at end of file -->
<Rule Id="SA1519" Action="None" /> <!-- Braces should not be omitted from multi-line child statement -->
<Rule Id="SA1520" Action="None" /> <!-- Use braces consistently -->
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.DocumentationRules">
<Rule Id="SA1600" Action="None" /> <!-- Elements should be documented -->
<Rule Id="SA1601" Action="None" /> <!-- Partial elements should be documented -->
<Rule Id="SA1602" Action="None" /> <!-- Enumeration items should be documented -->
<Rule Id="SA1603" Action="None" /> <!-- Documentation should contain valid XML -->
<Rule Id="SA1604" Action="None" /> <!-- Element documentation should have summary -->
<Rule Id="SA1605" Action="None" /> <!-- Partial element documentation should have summary -->
<Rule Id="SA1606" Action="None" /> <!-- Element documentation should have summary text -->
<Rule Id="SA1607" Action="None" /> <!-- Partial element documentation should have summary text -->
<Rule Id="SA1608" Action="None" /> <!-- Element documentation should not have default summary -->
<Rule Id="SA1609" Action="None" /> <!-- Property documentation should have value -->
<Rule Id="SA1610" Action="None" /> <!-- Property documentation should have value text -->
<Rule Id="SA1611" Action="None" /> <!-- Element parameters should be documented -->
<Rule Id="SA1612" Action="None" /> <!-- Element parameter documentation should match element parameters -->
<Rule Id="SA1613" Action="None" /> <!-- Element parameter documentation should declare parameter name -->
<Rule Id="SA1614" Action="None" /> <!-- Element parameter documentation should have text -->
<Rule Id="SA1615" Action="None" /> <!-- Element return value should be documented -->
<Rule Id="SA1616" Action="None" /> <!-- Element return value documentation should have text -->
<Rule Id="SA1617" Action="None" /> <!-- Void return value should not be documented -->
<Rule Id="SA1618" Action="None" /> <!-- Generic type parameters should be documented -->
<Rule Id="SA1619" Action="None" /> <!-- Generic type parameters should be documented partial class -->
<Rule Id="SA1620" Action="None" /> <!-- Generic type parameter documentation should match type parameters -->
<Rule Id="SA1621" Action="None" /> <!-- Generic type parameter documentation should declare parameter name -->
<Rule Id="SA1622" Action="None" /> <!-- Generic type parameter documentation should have text -->
<Rule Id="SA1623" Action="None" /> <!-- Property summary documentation should match accessors -->
<Rule Id="SA1624" Action="None" /> <!-- Property summary documentation should omit accessor with restricted access -->
<Rule Id="SA1625" Action="None" /> <!-- Element documentation should not be copied and pasted -->
<Rule Id="SA1626" Action="None" /> <!-- Single-line comments should not use documentation style slashes -->
<Rule Id="SA1627" Action="None" /> <!-- Documentation text should not be empty -->
<Rule Id="SA1628" Action="None" /> <!-- Documentation text should begin with a capital letter -->
<Rule Id="SA1629" Action="Info" /> <!-- Documentation text should end with a period -->
<Rule Id="SA1630" Action="None" /> <!-- Documentation text should contain whitespace -->
<Rule Id="SA1631" Action="None" /> <!-- Documentation should meet character percentage -->
<Rule Id="SA1632" Action="None" /> <!-- Documentation text should meet minimum character length -->
<Rule Id="SA1633" Action="Warning" /> <!-- File should have header -->
<Rule Id="SA1634" Action="Warning" /> <!-- File header should show copyright -->
<Rule Id="SA1635" Action="Warning" /> <!-- File header should have copyright text -->
<Rule Id="SA1636" Action="None" /> <!-- File header copyright text should match -->
<Rule Id="SA1637" Action="None" /> <!-- File header should contain file name -->
<Rule Id="SA1638" Action="None" /> <!-- File header file name documentation should match file name -->
<Rule Id="SA1639" Action="None" /> <!-- File header should have summary -->
<Rule Id="SA1640" Action="None" /> <!-- File header should have valid company text -->
<Rule Id="SA1641" Action="None" /> <!-- File header company name text should match -->
<Rule Id="SA1642" Action="None" /> <!-- Constructor summary documentation should begin with standard text -->
<Rule Id="SA1643" Action="None" /> <!-- Destructor summary documentation should begin with standard text -->
<Rule Id="SA1644" Action="None" /> <!-- Documentation headers should not contain blank lines -->
<Rule Id="SA1645" Action="None" /> <!-- Included documentation file does not exist -->
<Rule Id="SA1646" Action="None" /> <!-- Included documentation XPath does not exist -->
<Rule Id="SA1647" Action="None" /> <!-- Include node does not contain valid file and path -->
<Rule Id="SA1648" Action="None" /> <!-- Inheritdoc should be used with inheriting class -->
<Rule Id="SA1649" Action="Warning" /> <!-- File name should match first type name -->
<Rule Id="SA1650" Action="None" /> <!-- Element documentation should be spelled correctly -->
<Rule Id="SA1651" Action="None" /> <!-- Do not use placeholder elements -->
</Rules>
</RuleSet>

25
eng/Generate.ps1 Normal file
Просмотреть файл

@ -0,0 +1,25 @@
$ErrorActionPreference = "Stop"
function Invoke-Block([scriptblock]$cmd) {
$cmd | Out-String | Write-Verbose
& $cmd
# Need to check both of these cases for errors as they represent different items
# - $?: did the powershell script block throw an error
# - $lastexitcode: did a windows command executed by the script block end in error
if ((-not $?) -or ($lastexitcode -ne 0)) {
if ($error -ne $null)
{
Write-Warning $error[0]
}
throw "Command failed to execute: $cmd"
}
}
$repoRoot = "$PSScriptRoot\..\"
$paths = "$repoRoot\samples\Xkcd\readme.md", "$repoRoot\samples\Dns\readme.md"
foreach ($path in $paths)
{
Invoke-Block { npx autorest-beta --debug --verbose $path }
}

Двоичные данные
eng/MSSharedLibKey.snk Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -23,15 +23,21 @@ jobs:
npm install npm install
displayName: "Install packages" displayName: "Install packages"
- script: | - script: |
dotnet test AutoRest.CSharp.V3.sln -warnaserror dotnet build AutoRest.CSharp.V3.sln
displayName: "Build" displayName: "Build"
env: env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_MULTILEVEL_LOOKUP: 0 DOTNET_MULTILEVEL_LOOKUP: 0
- script: |
dotnet test AutoRest.CSharp.V3.sln
displayName: "Test"
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_MULTILEVEL_LOOKUP: 0
- script: | - script: |
npm install -g @autorest/autorest npm install -g @autorest/autorest
displayName: "Install autorest-beta" displayName: "Install autorest-beta"
- script: | - pwsh: eng\Generate.ps1
autorest-beta --debug --verbose --use:$(Build.SourcesDirectory) --input-file:$(Build.SourcesDirectory)\samples\xkcd\xkcd.yaml displayName: "Run autorest"
displayName: "Run autorest on xkcd"

10
eng/stylecop.json Normal file
Просмотреть файл

@ -0,0 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"copyrightText": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.",
"companyName": "Microsoft Corporation",
"xmlHeader": false
}
}
}

6
package-lock.json сгенерированный
Просмотреть файл

@ -3,6 +3,12 @@
"requires": true, "requires": true,
"lockfileVersion": 1, "lockfileVersion": 1,
"dependencies": { "dependencies": {
"@autorest/autorest": {
"version": "3.0.6122",
"resolved": "https://registry.npmjs.org/@autorest/autorest/-/autorest-3.0.6122.tgz",
"integrity": "sha512-A7eapUdRG/HRDAV6rVFHD/CyK4sAshaQjaAJBZJk9jBFxjUGSPMk1PjCFpP50pvZs5iL/EktBW1/ncFaw4SiTA==",
"dev": true
},
"@autorest/test-server": { "@autorest/test-server": {
"version": "3.0.26", "version": "3.0.26",
"resolved": "https://registry.npmjs.org/@autorest/test-server/-/test-server-3.0.26.tgz", "resolved": "https://registry.npmjs.org/@autorest/test-server/-/test-server-3.0.26.tgz",

Просмотреть файл

@ -4,10 +4,11 @@
"name": "@autorest/csharp-v3", "name": "@autorest/csharp-v3",
"description": "See readme.md for instructions", "description": "See readme.md for instructions",
"scripts": { "scripts": {
"start": "dotnet ./bin/AutoRest.CSharp.V3.dll --server", "start": "dotnet ./artifacts/bin/AutoRest.CSharp.V3/Debug/netcoreapp3.0/AutoRest.CSharp.V3.dll --server",
"debug": "dotnet ./bin/AutoRest.CSharp.V3.dll --server --launch-debugger" "debug": "dotnet ./artifacts/bin/AutoRest.CSharp.V3/Debug/netcoreapp3.0/AutoRest.CSharp.V3.dll --server --launch-debugger"
}, },
"devDependencies": { "devDependencies": {
"@autorest/test-server": "^3.0.26" "@autorest/autorest": "^3.0.6122",
"@autorest/test-server": "3.0.26"
} }
} }

Просмотреть файл

@ -5,7 +5,6 @@
```yaml ```yaml
use-extension: use-extension:
"@autorest/modelerfour": "4.1.58" "@autorest/modelerfour": "4.1.58"
include-csproj: true
pipeline: pipeline:
# serialize-tester: # serialize-tester:

Просмотреть файл

@ -3,32 +3,11 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>AutoRest.CSharp.V3</AssemblyName>
<RootNamespace>AutoRest.CSharp.V3</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>../../bin</OutputPath>
<PublishDir>$(OutputPath)</PublishDir>
<!-- Some methods are marked async and don't have an await in them -->
<NoWarn>1998</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild> <RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis> <RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DelaySign>false</DelaySign>
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Azure.Core" Version="1.0.0" /> <PackageReference Include="Azure.Core" Version="1.0.0" />
<PackageReference Include="Azure.Identity" Version="1.0.0" /> <PackageReference Include="Azure.Identity" Version="1.0.0" />

Просмотреть файл

@ -1,4 +1,7 @@
namespace AutoRest.CSharp.V3.CodeGen // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.CodeGen
{ {
internal class CsProjWriter : StringWriter internal class CsProjWriter : StringWriter
{ {

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.CodeGen namespace AutoRest.CSharp.V3.CodeGen

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using AutoRest.CSharp.V3.Pipeline; using AutoRest.CSharp.V3.Pipeline;

Просмотреть файл

@ -1,4 +1,7 @@
using AutoRest.CSharp.V3.Pipeline.Generated; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Pipeline.Generated;
using System; using System;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;

Просмотреть файл

@ -1,4 +1,7 @@
using System.Text; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Text;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Formatting;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;

Просмотреть файл

@ -1,4 +1,8 @@
using AutoRest.CSharp.V3.JsonRpc; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
namespace AutoRest.CSharp.V3 namespace AutoRest.CSharp.V3
{ {

Просмотреть файл

@ -1,131 +0,0 @@
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc
{
internal interface IMessage { }
internal class Message : IMessage
{
public Channel Channel { get; set; }
public string[]? Key { get; set; } = null;
public object? Details { get; set; } = null;
public string? Text { get; set; }
public SourceLocation[]? Source { get; set; } = null;
public override string ToString() =>
$@"{{""Channel"":""{Channel.ToString().ToLowerInvariant()}""{Key.TextOrEmpty($@",""Key"":{Key.ToJsonArray()}")}{Details.TextOrEmpty($@",""Details"":{Details}")},""Text"":""{Text.ToStringLiteral()}""{Source.TextOrEmpty($@",""Source"":{Source.ToJsonArray()}")}}}";
}
internal class ArtifactMessage : IMessage
{
public Channel Channel { get; set; }
public string[]? Key { get; set; } = null;
public IArtifact? Details { get; set; }
public string? Text { get; set; }
public SourceLocation[]? Source { get; set; } = null;
public override string ToString() =>
$@"{{""Channel"":""{Channel.ToString().ToLowerInvariant()}""{Key.TextOrEmpty($@",""Key"":{Key.ToJsonArray()}")},""Details"":{Details},""Text"":""{Text.ToStringLiteral()}""{Source.TextOrEmpty($@",""Source"":{Source.ToJsonArray()}")}}}";
}
internal interface IPosition { }
internal class Position : IPosition
{
// 1-based
public int Line { get; set; }
// 0-based
public int Column { get; set; }
public override string ToString() => $@"{{""line"":{Line},""column"":{Column}}}";
}
internal class PositionStringPath : IPosition
{
public string[]? Path { get; set; } = null;
public override string ToString() => $@"{{{Path.TextOrEmpty($@"""path"":{Path.ToJsonArray()}")}}}";
}
internal class PositionIntPath : IPosition
{
public int[]? Path { get; set; } = null;
public override string ToString() => $@"{{{Path.TextOrEmpty($@"""path"":{Path.ToJsonArray()}")}}}";
}
internal class SourceLocation
{
public string? Document { get; set; }
public IPosition? Position { get; set; }
public override string ToString() => $@"{{""document"":""{Document}"",""Position"":{Position}}}";
}
internal interface IArtifact { }
internal class ArtifactRaw : IArtifact
{
public string? Uri { get; set; }
public string? Type { get; set; }
public string? Content { get; set; }
public RawSourceMap? SourceMap { get; set; } = null;
public override string ToString() => $@"{{""uri"":""{Uri}"",""type"":""{Type}"",""content"":""{Content.ToStringLiteral()}""{SourceMap.TextOrEmpty($@",""sourceMap"":{SourceMap}")}}}";
}
internal class ArtifactMapping : IArtifact
{
public string? Uri { get; set; }
public string? Type { get; set; }
public string? Content { get; set; }
public Mapping[]? SourceMap { get; set; } = null;
public override string ToString() => $@"{{""uri"":""{Uri}"",""type"":""{Type}"",""content"":""{Content.ToStringLiteral()}""{SourceMap.TextOrEmpty($@",""sourceMap"":{SourceMap.ToJsonArray()}")}}}";
}
internal class RawSourceMap
{
public string? File { get; set; } = null;
public string? SourceRoot { get; set; } = null;
public string? Version { get; set; }
public string[]? Sources { get; set; }
public string[]? Names { get; set; }
public string[]? SourcesContent { get; set; } = null;
public string? Mappings { get; set; }
public override string ToString() => $@"{{""version"":""{Version}"",""sources"":{Sources.ToJsonArray()},""names"":{Names.ToJsonArray()},""mappings"":""{Mappings}""{File.TextOrEmpty($@",""file"":""{File}""")}{SourceRoot.TextOrEmpty($@",""sourceRoot"":""{SourceRoot}""")}{SourcesContent.TextOrEmpty($@",""sourcesContent"":{SourcesContent.ToJsonArray()}")}}}";
}
internal class Mapping
{
public Position? Generated { get; set; }
public Position? Original { get; set; }
public string? Source { get; set; }
public string? Name { get; set; } = null;
public override string ToString() => $@"{{""generated"":{Generated},""original"":{Original},""source"":""{Source}""{Name.TextOrEmpty($@",""name"":""{Name}""")}}}";
}
// The Channel that a message is registered with.
internal enum Channel
{
// Information is considered the mildest of responses; not necessarily actionable.
Information,
// Warnings are considered important for best practices, but not catastrophic in nature.
Warning,
// Errors are considered blocking issues that block a successful operation.
Error,
// Debug messages are designed for the developer to communicate internal AutoRest implementation details.
Debug,
// Verbose messages give the user additional clarity on the process.
Verbose,
// Catastrophic failure, likely aborting the process.
Fatal,
// Hint messages offer guidance or support without forcing action.
Hint,
// File represents a file output from an extension. Details are a Artifact and are required.
File,
// Content represents an update/creation of a configuration file. The final URI will be in the same folder as the primary config file.
Configuration,
// Protect is a path to not remove during a clear-output-folder.
Protect
}
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class ArtifactMapping : IArtifact
{
public string? Uri { get; set; }
public string? Type { get; set; }
public string? Content { get; set; }
public Mapping[]? SourceMap { get; set; } = null;
public override string ToString() => $@"{{""uri"":""{Uri}"",""type"":""{Type}"",""content"":""{Content.ToStringLiteral()}""{SourceMap.TextOrEmpty($@",""sourceMap"":{SourceMap.ToJsonArray()}")}}}";
}
}

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class ArtifactMessage : IMessage
{
public Channel Channel { get; set; }
public string[]? Key { get; set; } = null;
public IArtifact? Details { get; set; }
public string? Text { get; set; }
public SourceLocation[]? Source { get; set; } = null;
public override string ToString() =>
$@"{{""Channel"":""{Channel.ToString().ToLowerInvariant()}""{Key.TextOrEmpty($@",""Key"":{Key.ToJsonArray()}")},""Details"":{Details},""Text"":""{Text.ToStringLiteral()}""{Source.TextOrEmpty($@",""Source"":{Source.ToJsonArray()}")}}}";
}
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class ArtifactRaw : IArtifact
{
public string? Uri { get; set; }
public string? Type { get; set; }
public string? Content { get; set; }
public RawSourceMap? SourceMap { get; set; } = null;
public override string ToString() => $@"{{""uri"":""{Uri}"",""type"":""{Type}"",""content"":""{Content.ToStringLiteral()}""{SourceMap.TextOrEmpty($@",""sourceMap"":{SourceMap}")}}}";
}
}

Просмотреть файл

@ -1,8 +1,11 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc.Messaging; using AutoRest.CSharp.V3.JsonRpc.Messaging;
namespace AutoRest.CSharp.V3.JsonRpc namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{ {
internal class AutoRestInterface internal class AutoRestInterface
{ {

Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
// The Channel that a message is registered with.
internal enum Channel
{
// Information is considered the mildest of responses; not necessarily actionable.
Information,
// Warnings are considered important for best practices, but not catastrophic in nature.
Warning,
// Errors are considered blocking issues that block a successful operation.
Error,
// Debug messages are designed for the developer to communicate internal AutoRest implementation details.
Debug,
// Verbose messages give the user additional clarity on the process.
Verbose,
// Catastrophic failure, likely aborting the process.
Fatal,
// Hint messages offer guidance or support without forcing action.
Hint,
// File represents a file output from an extension. Details are a Artifact and are required.
File,
// Content represents an update/creation of a configuration file. The final URI will be in the same folder as the primary config file.
Configuration,
// Protect is a path to not remove during a clear-output-folder.
Protect
}
}

Просмотреть файл

@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -7,7 +10,7 @@ using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc.Messaging; using AutoRest.CSharp.V3.JsonRpc.Messaging;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{ {
internal delegate string IncomingRequestAction(Connection connection, IncomingRequest request); internal delegate string IncomingRequestAction(Connection connection, IncomingRequest request);
@ -41,11 +44,11 @@ namespace AutoRest.CSharp.V3.JsonRpc
public void Start() => _listener.GetAwaiter().GetResult(); public void Start() => _listener.GetAwaiter().GetResult();
private async Task<bool> Listen() private Task<bool> Listen()
{ {
bool IsAlive() => !_cancellationToken.IsCancellationRequested; bool IsAlive() => !_cancellationToken.IsCancellationRequested;
while (IsAlive() && _incomingMessageProcessor.ProcessStream()) { } while (IsAlive() && _incomingMessageProcessor.ProcessStream()) { }
return false; return Task.FromResult(false);
} }
private void HandleIncomingRequest(IncomingRequest request) private void HandleIncomingRequest(IncomingRequest request)

Просмотреть файл

@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal interface IArtifact { }
}

Просмотреть файл

@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal interface IMessage { }
}

Просмотреть файл

@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal interface IPosition { }
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class Mapping
{
public Position? Generated { get; set; }
public Position? Original { get; set; }
public string? Source { get; set; }
public string? Name { get; set; } = null;
public override string ToString() => $@"{{""generated"":{Generated},""original"":{Original},""source"":""{Source}""{Name.TextOrEmpty($@",""name"":""{Name}""")}}}";
}
}

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class Message : IMessage
{
public Channel Channel { get; set; }
public string[]? Key { get; set; } = null;
public object? Details { get; set; } = null;
public string? Text { get; set; }
public SourceLocation[]? Source { get; set; } = null;
public override string ToString() =>
$@"{{""Channel"":""{Channel.ToString().ToLowerInvariant()}""{Key.TextOrEmpty($@",""Key"":{Key.ToJsonArray()}")}{Details.TextOrEmpty($@",""Details"":{Details}")},""Text"":""{Text.ToStringLiteral()}""{Source.TextOrEmpty($@",""Source"":{Source.ToJsonArray()}")}}}";
}
}

Просмотреть файл

@ -1,11 +1,14 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Text; using System.Text;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{ {
[SuppressMessage("ReSharper", "IdentifierTypo")] [SuppressMessage("ReSharper", "IdentifierTypo")]
internal class PeekableBinaryStream : IDisposable internal class PeekableBinaryStream : IDisposable

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class Position : IPosition
{
// 1-based
public int Line { get; set; }
// 0-based
public int Column { get; set; }
public override string ToString() => $@"{{""line"":{Line},""column"":{Column}}}";
}
}

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class PositionIntPath : IPosition
{
public int[]? Path { get; set; } = null;
public override string ToString() => $@"{{{Path.TextOrEmpty($@"""path"":{Path.ToJsonArray()}")}}}";
}
}

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class PositionStringPath : IPosition
{
public string[]? Path { get; set; } = null;
public override string ToString() => $@"{{{Path.TextOrEmpty($@"""path"":{Path.ToJsonArray()}")}}}";
}
}

Просмотреть файл

@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class RawSourceMap
{
public string? File { get; set; } = null;
public string? SourceRoot { get; set; } = null;
public string? Version { get; set; }
public string[]? Sources { get; set; }
public string[]? Names { get; set; }
public string[]? SourcesContent { get; set; } = null;
public string? Mappings { get; set; }
public override string ToString() => $@"{{""version"":""{Version}"",""sources"":{Sources.ToJsonArray()},""names"":{Names.ToJsonArray()},""mappings"":""{Mappings}""{File.TextOrEmpty($@",""file"":""{File}""")}{SourceRoot.TextOrEmpty($@",""sourceRoot"":""{SourceRoot}""")}{SourcesContent.TextOrEmpty($@",""sourcesContent"":{SourcesContent.ToJsonArray()}")}}}";
}
}

Просмотреть файл

@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.MessageModels
{
internal class SourceLocation
{
public string? Document { get; set; }
public IPosition? Position { get; set; }
public override string ToString() => $@"{{""document"":""{Document}"",""Position"":{Position}}}";
}
}

Просмотреть файл

@ -1,7 +1,10 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Linq; using System.Linq;
using System.Text;
using System.Text.Json; using System.Text.Json;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.Messaging namespace AutoRest.CSharp.V3.JsonRpc.Messaging
@ -77,18 +80,4 @@ namespace AutoRest.CSharp.V3.JsonRpc.Messaging
} }
} }
} }
internal static class PeekingBinaryReaderExtensions
{
public static bool IsJsonBlock(this byte? value) => '{' == value || '[' == value;
public static JsonElement? ReadJson(this PeekableBinaryStream stream, int contentLength) => Encoding.UTF8.GetString(stream.ReadBytes(contentLength)).Parse();
public static JsonElement? ReadJson(this PeekableBinaryStream stream)
{
var sb = new StringBuilder();
// ReSharper disable once IteratorMethodResultIsIgnored
stream.ReadAllAsciiLines(l => sb.Append(l).ToString().Parse() != null);
return sb.ToString().Parse();
}
}
} }

Просмотреть файл

@ -1,6 +1,9 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
using System.Text.Json; // Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Threading; using System.Threading;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.Messaging namespace AutoRest.CSharp.V3.JsonRpc.Messaging
@ -24,19 +27,4 @@ namespace AutoRest.CSharp.V3.JsonRpc.Messaging
return String.Empty; return String.Empty;
} }
} }
internal class IncomingRequest
{
public string JsonRpc { get; } = "2.0";
public string? Method { get; set; }
public JsonElement? Params { get; set; }
public string? Id { get; set; }
}
internal class IncomingResponse
{
public string JsonRpc { get; } = "2.0";
public string? Result { get; set; }
public string? Id { get; set; }
}
} }

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Text.Json;
namespace AutoRest.CSharp.V3.JsonRpc.Messaging
{
internal class IncomingRequest
{
public string JsonRpc { get; } = "2.0";
public string? Method { get; set; }
public JsonElement? Params { get; set; }
public string? Id { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.JsonRpc.Messaging
{
internal class IncomingResponse
{
public string JsonRpc { get; } = "2.0";
public string? Result { get; set; }
public string? Id { get; set; }
}
}

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading; using System.Threading;

Просмотреть файл

@ -1,4 +1,8 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.Messaging namespace AutoRest.CSharp.V3.JsonRpc.Messaging

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Text;
using System.Text.Json;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Utilities;
namespace AutoRest.CSharp.V3.JsonRpc.Messaging
{
internal static class PeekingBinaryReaderExtensions
{
public static bool IsJsonBlock(this byte? value) => '{' == value || '[' == value;
public static JsonElement? ReadJson(this PeekableBinaryStream stream, int contentLength) => Encoding.UTF8.GetString(stream.ReadBytes(contentLength)).Parse();
public static JsonElement? ReadJson(this PeekableBinaryStream stream)
{
var sb = new StringBuilder();
// ReSharper disable once IteratorMethodResultIsIgnored
stream.ReadAllAsciiLines(l => sb.Append(l).ToString().Parse() != null);
return sb.ToString().Parse();
}
}
}

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
@ -6,6 +9,7 @@ using AutoRest.CSharp.V3.Utilities;
using YamlDotNet.Core; using YamlDotNet.Core;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
#pragma warning disable SA1402
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. #pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace AutoRest.CSharp.V3.Pipeline.Generated namespace AutoRest.CSharp.V3.Pipeline.Generated

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

Просмотреть файл

@ -1,10 +1,14 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline; using AutoRest.CSharp.V3.Pipeline;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
using AutoRest.CSharp.V3.Plugins; using AutoRest.CSharp.V3.Plugins;

Просмотреть файл

@ -1,8 +1,12 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.CodeGen; using AutoRest.CSharp.V3.CodeGen;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.Plugins namespace AutoRest.CSharp.V3.Plugins

Просмотреть файл

@ -1,6 +1,10 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.Plugins namespace AutoRest.CSharp.V3.Plugins

Просмотреть файл

@ -1,7 +1,11 @@
using System.Linq; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.CodeGen; using AutoRest.CSharp.V3.CodeGen;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline; using AutoRest.CSharp.V3.Pipeline;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;

Просмотреть файл

@ -1,6 +1,10 @@
using System.Linq; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline; using AutoRest.CSharp.V3.Pipeline;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
@ -12,7 +16,7 @@ namespace AutoRest.CSharp.V3.Plugins
// ReSharper disable once IdentifierTypo // ReSharper disable once IdentifierTypo
internal class Namer : IPlugin internal class Namer : IPlugin
{ {
public async Task<bool> Execute(AutoRestInterface autoRest, CodeModel codeModel, Configuration configuration) public Task<bool> Execute(AutoRestInterface autoRest, CodeModel codeModel, Configuration configuration)
{ {
var schemaNodes = codeModel.Schemas.GetAllSchemaNodes(); var schemaNodes = codeModel.Schemas.GetAllSchemaNodes();
foreach (var schema in schemaNodes) foreach (var schema in schemaNodes)
@ -71,7 +75,7 @@ namespace AutoRest.CSharp.V3.Plugins
} }
} }
return true; return Task.FromResult(true);
} }
} }
} }

Просмотреть файл

@ -1,6 +1,9 @@
using System.Threading.Tasks; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Threading.Tasks;
using AutoRest.CSharp.V3.CodeGen; using AutoRest.CSharp.V3.CodeGen;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.Plugins namespace AutoRest.CSharp.V3.Plugins

Просмотреть файл

@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Simplification;
namespace AutoRest.CSharp.V3.Plugins.PostGen
{
internal static class RoslynExtensions
{
public static T AddSimplifierAnnotation<T>(this T node) where T : SyntaxNode => node.WithAdditionalAnnotations(Simplifier.Annotation);
}
}

Просмотреть файл

@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Simplification;
namespace AutoRest.CSharp.V3.Plugins.PostGen namespace AutoRest.CSharp.V3.Plugins.PostGen
{ {
@ -24,9 +23,4 @@ namespace AutoRest.CSharp.V3.Plugins.PostGen
public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node) => base.VisitIdentifierName(node.AddSimplifierAnnotation()); public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node) => base.VisitIdentifierName(node.AddSimplifierAnnotation());
public override SyntaxNode VisitGenericName(GenericNameSyntax node) => base.VisitGenericName(node.AddSimplifierAnnotation()); public override SyntaxNode VisitGenericName(GenericNameSyntax node) => base.VisitGenericName(node.AddSimplifierAnnotation());
} }
internal static class RoslynExtensions
{
public static T AddSimplifierAnnotation<T>(this T node) where T : SyntaxNode => node.WithAdditionalAnnotations(Simplifier.Annotation);
}
} }

Просмотреть файл

@ -13,6 +13,7 @@ using System.Net;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
using System.Net.Http; using System.Net.Http;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
namespace AutoRest.CSharp.V3.Plugins.PostGen namespace AutoRest.CSharp.V3.Plugins.PostGen
{ {

Просмотреть файл

@ -1,8 +1,12 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline; using AutoRest.CSharp.V3.Pipeline;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;

Просмотреть файл

@ -1,10 +1,14 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.Pipeline; using AutoRest.CSharp.V3.Pipeline;
using AutoRest.CSharp.V3.Pipeline.Generated; using AutoRest.CSharp.V3.Pipeline.Generated;
using AutoRest.CSharp.V3.Utilities; using AutoRest.CSharp.V3.Utilities;
@ -15,7 +19,7 @@ namespace AutoRest.CSharp.V3.Plugins
[PluginName("cs-typer")] [PluginName("cs-typer")]
internal class Typer : IPlugin internal class Typer : IPlugin
{ {
public async Task<bool> Execute(AutoRestInterface autoRest, CodeModel codeModel, Configuration configuration) public Task<bool> Execute(AutoRestInterface autoRest, CodeModel codeModel, Configuration configuration)
{ {
//TODO: Redo this entire processing logic. It is quite complex. //TODO: Redo this entire processing logic. It is quite complex.
var allSchemas = codeModel.Schemas.GetAllSchemaNodes(); var allSchemas = codeModel.Schemas.GetAllSchemaNodes();
@ -60,7 +64,7 @@ namespace AutoRest.CSharp.V3.Plugins
}; };
} }
return true; return Task.FromResult(true);
} }
// This unique identifier to objectively compare schemas for processing. // This unique identifier to objectively compare schemas for processing.

Просмотреть файл

@ -1,8 +1,12 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using AutoRest.CSharp.V3.JsonRpc; using AutoRest.CSharp.V3.JsonRpc;
using AutoRest.CSharp.V3.JsonRpc.MessageModels;
using AutoRest.CSharp.V3.JsonRpc.Messaging; using AutoRest.CSharp.V3.JsonRpc.Messaging;
namespace AutoRest.CSharp.V3 namespace AutoRest.CSharp.V3

Просмотреть файл

@ -2,9 +2,8 @@
"profiles": { "profiles": {
"AutoRest.CSharp.V3": { "AutoRest.CSharp.V3": {
"commandName": "Executable", "commandName": "Executable",
"executablePath": "node", "executablePath": "$(APPDATA)\\npm\\npx.cmd",
"commandLineArgs": "%appdata%/npm/node_modules/@autorest/autorest/entrypoints/app.js --debug --verbose --use:$(ProjectDir)../.. --required:$(ProjectDir)../../samples/Xkcd/readme.md --model-creator.debugger", "commandLineArgs": "autorest-beta --cs-modeler.attach $(ProjectDir)../../samples/Xkcd/readme.md"
"workingDirectory": "$(ProjectDir)../.."
} }
} }
} }

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using Azure.Core; using Azure.Core;
namespace AutoRest.CSharp.V3.Utilities namespace AutoRest.CSharp.V3.Utilities

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace AutoRest.CSharp.V3.Utilities namespace AutoRest.CSharp.V3.Utilities

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace AutoRest.CSharp.V3.Utilities namespace AutoRest.CSharp.V3.Utilities

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;

Просмотреть файл

@ -3,14 +3,6 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<RootNamespace>AutoRest.CodeModel</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin</OutputPath>
<PublishDir>$(OutputPath)</PublishDir>
<!-- Some methods are marked async and don't have an await in them -->
<NoWarn>1998</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;

Просмотреть файл

@ -1,4 +1,7 @@
using System; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -13,7 +16,8 @@ namespace AutoRest.CodeModel
string? line; string? line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)
{ {
if (removeEmptyLines && String.IsNullOrWhiteSpace(line)) continue; if (removeEmptyLines && String.IsNullOrWhiteSpace(line))
continue;
yield return line; yield return line;
} }
} }

Просмотреть файл

@ -1,4 +1,7 @@
using System.IO; // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.IO;
using System.Net; using System.Net;
namespace AutoRest.CodeModel namespace AutoRest.CodeModel

Просмотреть файл

@ -2,9 +2,9 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<Nullable>annotations</Nullable> <Nullable>annotations</Nullable>
<NoWarn>SA1649;SA1633</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Просмотреть файл

@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -174,14 +177,14 @@ namespace AutoRest.TestServer.Tests
} }
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
static extern IntPtr CreateJobObject(IntPtr lpJobAttributes, string name); private static extern IntPtr CreateJobObject(IntPtr lpJobAttributes, string name);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
static extern bool SetInformationJobObject(IntPtr job, JobObjectInfoType infoType, private static extern bool SetInformationJobObject(IntPtr job, JobObjectInfoType infoType,
IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength); IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process); private static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
private enum JobObjectInfoType private enum JobObjectInfoType
{ {

Просмотреть файл

@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System; using System;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;

Просмотреть файл

@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System; using System;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;