Skip to content

Commit c4e14bd

Browse files
authored
Merge pull request #117 from AArnott/freshenup
Target newer frameworks and SDKs
2 parents 499b25e + d51e370 commit c4e14bd

16 files changed

+48
-38
lines changed

azure-pipelines.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
trigger:
22
branches:
3-
include: ["master"]
3+
include:
4+
- master
45
paths:
5-
exclude: ["doc", "*.md", ".appveyor.yml", ".travis.yml"]
6+
exclude: ["doc", "*.md"]
67

78
variables:
89
# TreatWarningsAsErrors: true
@@ -12,14 +13,19 @@ variables:
1213

1314
jobs:
1415
- job: Windows
15-
pool: Hosted VS2017
16+
pool: Hosted Windows 2019 with VS2019
1617
steps:
1718
- script: |
1819
dotnet tool install --tool-path . nbgv
1920
.\nbgv cloud -p src
2021
displayName: Set build number
2122
condition: ne(variables['system.pullrequest.isfork'], true)
2223
24+
- task: UseDotNet@2
25+
displayName: Install .NET Core SDK
26+
inputs:
27+
version: 2.2.401
28+
2329
- script: dotnet --info
2430
displayName: Show dotnet SDK info
2531

@@ -35,7 +41,7 @@ jobs:
3541
# Use VSBuild on Windows so GitLink will work (it fails on dotnet build)
3642
- task: VSBuild@1
3743
inputs:
38-
vsVersion: 15.0
44+
vsVersion: "16.0"
3945
msbuildArgs: /t:build,pack /m /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
4046
platform: $(BuildPlatform)
4147
configuration: $(BuildConfiguration)

src/Directory.Build.targets

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<Project>
22
<PropertyGroup>
3-
<CodeGenerationRoslynVersion>0.4.88</CodeGenerationRoslynVersion>
3+
<CodeGenerationRoslynVersion>0.6.1</CodeGenerationRoslynVersion>
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageReference Update="CodeGeneration.Roslyn.Attributes" Version="$(CodeGenerationRoslynVersion)" />
7-
<PackageReference Update="CodeGeneration.Roslyn" Version="$(CodeGenerationRoslynVersion)" />
87
<PackageReference Update="CodeGeneration.Roslyn.BuildTime" Version="$(CodeGenerationRoslynVersion)" />
9-
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.9.0" />
8+
<PackageReference Update="CodeGeneration.Roslyn" Version="$(CodeGenerationRoslynVersion)" />
9+
<PackageReference Update="CodeGeneration.Roslyn.Engine" Version="$(CodeGenerationRoslynVersion)" />
10+
<PackageReference Update="Microsoft.Build" Version="14.3.0" />
11+
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.1.0" />
12+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.2.0" />
1013
<PackageReference Update="System.Collections.Immutable" Version="1.5.0" />
1114
<PackageReference Update="System.Diagnostics.Contracts" Version="4.3.0" />
12-
<PackageReference Update="Validation" Version="2.4.18" />
13-
<PackageReference Update="Microsoft.Build" Version="14.3.0" />
14-
<PackageReference Update="xunit" Version="2.3.1" />
15-
<PackageReference Update="xunit.runner.visualstudio" Version="2.3.1" />
15+
<PackageReference Update="Validation" Version="2.4.22" />
16+
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.1" />
17+
<PackageReference Update="xunit" Version="2.4.1" />
1618
</ItemGroup>
1719
<ItemGroup>
1820
<DotNetCliToolReference Update="dotnet-codegen" Version="$(CodeGenerationRoslynVersion)" />

src/ImmutableObjectGraph.Generation.Attributes/GenerateImmutableAttribute.cs

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

77
[AttributeUsage(AttributeTargets.Class)]
88
[Conditional("CodeGeneration")]
9-
[CodeGenerationAttribute("ImmutableObjectGraph.Generation.CodeGenerator, ImmutableObjectGraph.Generation, Version=" + ThisAssembly.AssemblyVersion + ", Culture=neutral, PublicKeyToken=bfd91f1bd601e0d7")]
9+
[CodeGenerationAttribute("ImmutableObjectGraph.Generation.CodeGenerator, ImmutableObjectGraph.Generation, Version=" + ThisAssembly.AssemblyVersion + ", Culture=neutral, PublicKeyToken=" + ThisAssembly.PublicKeyToken)]
1010
public class GenerateImmutableAttribute : Attribute
1111
{
1212
public GenerateImmutableAttribute()

src/ImmutableObjectGraph.Generation.Attributes/ImmutableObjectGraph.Generation.Attributes.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="MSBuild.Sdk.Extras">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<RootNamespace>ImmutableObjectGraph.Generation</RootNamespace>
4-
<TargetFrameworks>netstandard1.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<Description>The runtime components behind the types generated with the ImmutableObjectGraph.Generation package.</Description>
66

77
<!-- This gets included in ImmutableObjectGraph.Generation -->

src/ImmutableObjectGraph.Generation.Tests/CodeGenTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
using System.Text;
1010
using System.Threading;
1111
using System.Threading.Tasks;
12+
using CodeGeneration.Roslyn.Engine;
1213
using global::CodeGeneration.Roslyn;
14+
using ImmutableObjectGraph.Generation.Roslyn;
1315
using Microsoft.CodeAnalysis;
1416
using Microsoft.CodeAnalysis.CSharp;
1517
using Microsoft.CodeAnalysis.Diagnostics;
@@ -34,8 +36,7 @@ public CodeGenTests(ITestOutputHelper logger)
3436
var workspace = new AdhocWorkspace();
3537
var project = workspace.CurrentSolution.AddProject("test", "test", "C#")
3638
.WithCompilationOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
37-
.AddMetadataReferences(GetReferences("Profile78"))
38-
.AddMetadataReference(MetadataReference.CreateFromFile(Assembly.Load("netstandard, Version=2.0.0.0").Location))
39+
.AddMetadataReferences(GetNetStandard20References())
3940
.AddMetadataReference(MetadataReference.CreateFromFile(typeof(GenerateImmutableAttribute).Assembly.Location))
4041
.AddMetadataReference(MetadataReference.CreateFromFile(typeof(CodeGenerationAttributeAttribute).Assembly.Location))
4142
.AddMetadataReference(MetadataReference.CreateFromFile(typeof(Optional).Assembly.Location))
@@ -335,10 +336,11 @@ private static string EscapeLineEndingCharacters(string whitespace)
335336
return builder.ToString();
336337
}
337338

338-
private static IEnumerable<MetadataReference> GetReferences(string profile)
339+
private static IEnumerable<MetadataReference> GetNetStandard20References()
339340
{
340-
string profileDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile", profile);
341-
foreach (string assembly in Directory.GetFiles(profileDirectory, "*.dll"))
341+
string nugetPackageRoot = Environment.GetEnvironmentVariable("NUGET_PACKAGES") ?? Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\.nuget\packages");
342+
string netstandardRoot = Path.Combine(nugetPackageRoot, @"netstandard.library\2.0.3\build\netstandard2.0\ref");
343+
foreach (string assembly in Directory.GetFiles(netstandardRoot, "*.dll"))
342344
{
343345
yield return MetadataReference.CreateFromFile(assembly);
344346
}

src/ImmutableObjectGraph.Generation.Tests/ImmutableObjectGraph.Generation.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net461</TargetFramework>
4-
5-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
6-
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
3+
<TargetFrameworks>net472</TargetFrameworks>
74
</PropertyGroup>
85
<ItemGroup>
96
<Compile Update="TestSources\AbstractClassMidTypeHierarchyWithRequiredField.cs">
@@ -82,10 +79,13 @@
8279
</ItemGroup>
8380
<ItemGroup>
8481
<PackageReference Include="Microsoft.Build" />
82+
<PackageReference Include="Validation" />
8583
<PackageReference Include="xunit" />
8684
<PackageReference Include="xunit.runner.visualstudio" />
8785
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" PrivateAssets="all" />
86+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
8887
<PackageReference Include="CodeGeneration.Roslyn" PrivateAssets="all" />
88+
<PackageReference Include="CodeGeneration.Roslyn.Engine" PrivateAssets="all" />
8989
</ItemGroup>
9090
<ItemGroup>
9191
<DotNetCliToolReference Include="dotnet-codegen" />
@@ -95,4 +95,4 @@
9595
<ProjectReference Include="..\ImmutableObjectGraph.Generation\ImmutableObjectGraph.Generation.csproj" />
9696
<ProjectReference Include="..\ImmutableObjectGraph\ImmutableObjectGraph.csproj" />
9797
</ItemGroup>
98-
</Project>
98+
</Project>

src/ImmutableObjectGraph.Generation/CodeGen.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Threading;
1313
using System.Threading.Tasks;
1414
using global::CodeGeneration.Roslyn;
15+
using ImmutableObjectGraph.Generation.Roslyn;
1516
using Microsoft.CodeAnalysis;
1617
using Microsoft.CodeAnalysis.CSharp;
1718
using Microsoft.CodeAnalysis.CSharp.Syntax;

src/ImmutableObjectGraph.Generation/ImmutableObjectGraph.Generation.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<RootNamespace>ImmutableObjectGraph.Generation</RootNamespace>
4-
<TargetFramework>netstandard1.6</TargetFramework>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<Description>MSBuild-based code generator to transform simple mutable type definitions into fully functional immutable types with persistent characteristics.</Description>
66

77
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -36,6 +36,7 @@
3636
<PackageReference Include="CodeGeneration.Roslyn" PrivateAssets="all" />
3737
<PackageReference Include="CodeGeneration.Roslyn.BuildTime" PrivateAssets="none" />
3838
<PackageReference Include="System.Diagnostics.Contracts" PrivateAssets="all" />
39+
<PackageReference Include="Validation" PrivateAssets="all" />
3940
</ItemGroup>
4041
<ItemGroup>
4142
<DotNetCliToolReference Include="dotnet-codegen" />
@@ -57,4 +58,4 @@
5758
<NuspecProperties>id=$(PackageId);version=$(NuGetPackageVersion);authors=$(Authors);copyright=$(Copyright);tags=$(PackageTags);requireLicenseAcceptance=$(PackageRequireLicenseAcceptance);licenseUrl=$(PackageLicenseUrl);description=$(Description);CodeGenerationRoslynVersion=$(CodeGenerationRoslynVersion);Configuration=$(Configuration);OutDir=$(OutDir)</NuspecProperties>
5859
</PropertyGroup>
5960
</Target>
60-
</Project>
61+
</Project>

src/ImmutableObjectGraph.Generation/ImmutableObjectGraph.Generation.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<copyright>$Copyright$</copyright>
1212
<tags>$PackageTags$</tags>
1313
<dependencies>
14-
<group targetFramework=".NETStandard1.0">
14+
<group targetFramework=".NETStandard2.0">
1515
<dependency id="CodeGeneration.Roslyn.BuildTime" version="$CodeGenerationRoslynVersion$" />
1616
<dependency id="ImmutableObjectGraph" version="$version$" />
1717
</group>
@@ -25,6 +25,6 @@
2525
<file src="..\..\lib\netstandard1.0\CG.Pluralization.dll" target="tools\" />
2626
<file src="Readme.txt" target="Readme.txt" />
2727
<file src="build\*" target="build\" />
28-
<file src="..\..\bin\ImmutableObjectGraph.Generation.Attributes\$Configuration$\netstandard1.0\ImmutableObjectGraph.Generation.Attributes.dll" target="lib\netstandard1.0\" />
28+
<file src="..\..\bin\ImmutableObjectGraph.Generation.Attributes\$Configuration$\netstandard2.0\ImmutableObjectGraph.Generation.Attributes.dll" target="lib\netstandard2.0\" />
2929
</files>
3030
</package>

src/ImmutableObjectGraph.Generation/Roslyn/CSharpDeclarationComputer.cs

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

1414
namespace ImmutableObjectGraph.Generation.Roslyn
1515
{
16-
internal class CSharpDeclarationComputer : DeclarationComputer
16+
public class CSharpDeclarationComputer : DeclarationComputer
1717
{
1818
public static ImmutableArray<DeclarationInfo> GetDeclarationsInSpan(SemanticModel model, TextSpan span, bool getSymbol, CancellationToken cancellationToken)
1919
{

0 commit comments

Comments
 (0)