Skip to content

Commit

Permalink
Move to 3.8.0-3.final Roslyn packages (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Sep 21, 2020
1 parent 4bb5cb0 commit f56021b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
7 changes: 7 additions & 0 deletions DllImportGenerator/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>

<PropertyGroup>
<CompilerPlatformVersion>3.8.0-3.final</CompilerPlatformVersion>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.7.0-3.final" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0-beta1.final" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(CompilerPlatformVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.0.1-beta1.20418.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.7.0-3.final">
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="$(CompilerPlatformVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 3 additions & 5 deletions DllImportGenerator/DllImportGenerator.Test/TestUtils.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -70,14 +69,13 @@ public static (ReferenceAssemblies, MetadataReference) GetReferenceAssemblies()
/// <returns>The resulting compilation</returns>
public static Compilation RunGenerators(Compilation comp, out ImmutableArray<Diagnostic> diagnostics, params ISourceGenerator[] generators)
{
CreateDriver(comp, generators).RunFullGeneration(comp, out var d, out diagnostics);
CreateDriver(comp, generators).RunGeneratorsAndUpdateCompilation(comp, out var d, out diagnostics);
return d;
}

private static GeneratorDriver CreateDriver(Compilation c, params ISourceGenerator[] generators)
=> new CSharpGeneratorDriver(c.SyntaxTrees.First().Options,
=> CSharpGeneratorDriver.Create(
ImmutableArray.Create(generators),
null,
ImmutableArray<AdditionalText>.Empty);
parseOptions: (CSharpParseOptions)c.SyntaxTrees.First().Options);
}
}
4 changes: 2 additions & 2 deletions DllImportGenerator/DllImportGenerator/DllImportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DllImportGenerator : ISourceGenerator
private const string GeneratedDllImport = nameof(GeneratedDllImport);
private const string GeneratedDllImportAttribute = nameof(GeneratedDllImportAttribute);

public void Execute(SourceGeneratorContext context)
public void Execute(GeneratorExecutionContext context)
{
var synRec = context.SyntaxReceiver as SyntaxReceiver;
if (synRec is null)
Expand Down Expand Up @@ -70,7 +70,7 @@ public void Execute(SourceGeneratorContext context)
context.AddSource("DllImportGenerator.g.cs", SourceText.From(generatedDllImports.ToString(), Encoding.UTF8));
}

public void Initialize(InitializationContext context)
public void Initialize(GeneratorInitializationContext context)
{
context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.7.0-3.final" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0-beta1.final" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(CompilerPlatformVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ public static bool IsAutoLayout(this INamedTypeSymbol type, ITypeSymbol structLa

public static TypeSyntax AsTypeSyntax(this ITypeSymbol type)
{
// [TODO] Use ParseTypeName overload with default values for offset and consumeFullText after switching
// to Roslyn package that has the change from CSharpParseOptions -> ParseOptions in that overload
// return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat));
return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), offset: 0, consumeFullText: true);
return SyntaxFactory.ParseTypeName(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat));
}
}
}

0 comments on commit f56021b

Please sign in to comment.