Skip to content

Commit

Permalink
Fix netstandard2.0 compatibility (dotnet#6549)
Browse files Browse the repository at this point in the history
  • Loading branch information
pentp authored May 24, 2020
1 parent 0cc59a2 commit 0fd14f4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
11 changes: 7 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ dotnet_style_parentheses_in_relational_binary_operators = n
dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion
dotnet_style_predefined_type_for_member_access = true : suggestion
dotnet_style_prefer_auto_properties = true : suggestion
dotnet_style_prefer_compound_assignment = true : suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true : suggestion
dotnet_style_prefer_conditional_expression_over_return = true : suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true : suggestion
dotnet_style_prefer_inferred_tuple_names = true : suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true : suggestion
dotnet_style_qualification_for_event = true : suggestion
dotnet_style_qualification_for_field = true : suggestion
dotnet_style_qualification_for_method = true : suggestion
dotnet_style_qualification_for_property = true : suggestion
dotnet_style_qualification_for_event = false : silent
dotnet_style_qualification_for_field = false : silent
dotnet_style_qualification_for_method = false : silent
dotnet_style_qualification_for_property = false : silent
dotnet_style_require_accessibility_modifiers = always : suggestion

# Naming Symbols
Expand Down Expand Up @@ -168,6 +169,8 @@ csharp_style_expression_bodied_indexers = true
csharp_style_expression_bodied_methods = when_on_single_line : suggestion
csharp_style_expression_bodied_operators = when_on_single_line : suggestion
csharp_style_expression_bodied_properties = true : suggestion
csharp_style_expression_bodied_lambdas = true : suggestion
csharp_style_expression_bodied_local_functions = when_on_single_line : suggestion
csharp_style_inlined_variable_declaration = true : suggestion
csharp_style_pattern_local_over_anonymous_function = true : suggestion
csharp_style_pattern_matching_over_as_with_null_check = true : suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -201,7 +200,8 @@ private MemberDeclarationSyntax[] GenerateInvokeMethods(GrainInterfaceDescriptio
var done = wellKnownTypes.Task.ToNameSyntax().Member((object _) => Task.CompletedTask);
body.Add(ReturnStatement(done));
}
else if (SymbolEqualityComparer.Default.Equals(wellKnownTypes.ValueTaskNamed, method.ReturnType))
else if (wellKnownTypes.ValueTask is WellKnownTypes.Some valueTask
&& SymbolEqualityComparer.Default.Equals(valueTask.Value, method.ReturnType))
{
body.Add(ReturnStatement(LiteralExpression(SyntaxKind.DefaultLiteralExpression)));
}
Expand All @@ -211,8 +211,6 @@ private MemberDeclarationSyntax[] GenerateInvokeMethods(GrainInterfaceDescriptio
$"Method {method} is marked with [{wellKnownTypes.OneWayAttribute.Name}], " +
$"but has a return type which is not assignable from {typeof(Task)} or {typeof(ValueTask)}");
}


}
}
else if (method.ReturnType is INamedTypeSymbol methodReturnType)
Expand Down
2 changes: 0 additions & 2 deletions src/Orleans.CodeGenerator/WellKnownTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public WellKnownTypes(Compilation compilation)
SerializerFeature = Type("Orleans.Serialization.SerializerFeature");
String = compilation.GetSpecialType(SpecialType.System_String);
Task = Type("System.Threading.Tasks.Task");
ValueTaskNamed = Type("System.Threading.Tasks.ValueTask");
Task_1 = Type("System.Threading.Tasks.Task`1");
ValueTask = OptionalType("System.Threading.Tasks.ValueTask");
TimeSpan = Type("System.TimeSpan");
Expand Down Expand Up @@ -221,7 +220,6 @@ INamedTypeSymbol ResolveType(string type)
public INamedTypeSymbol String { get; }
public INamedTypeSymbol Task { get; }
public INamedTypeSymbol Task_1 { get; }
public INamedTypeSymbol ValueTaskNamed { get; }
public OptionalType ValueTask { get; }
public INamedTypeSymbol TransactionAttribute { get; }
public INamedTypeSymbol TransactionOption { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsVersion)" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="RoslynTypeNameFormatterTests.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ IEnumerable<MetadataReference> GetGlobalReferences()
MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "System.dll")),
MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "System.Core.dll")),
MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "System.Runtime.dll")),

#if NET461
MetadataReference.CreateFromFile(typeof(ValueTask).Assembly.Location),
#endif

MetadataReference.CreateFromFile(Path.Combine(assemblyPath, "System.Runtime.Serialization.Formatters.dll"))
};
}
Expand Down

0 comments on commit 0fd14f4

Please sign in to comment.