Skip to content

Commit

Permalink
Merge pull request #117 from AArnott/freshenup
Browse files Browse the repository at this point in the history
Target newer frameworks and SDKs
  • Loading branch information
AArnott authored Sep 9, 2019
2 parents 499b25e + d51e370 commit c4e14bd
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 38 deletions.
14 changes: 10 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
trigger:
branches:
include: ["master"]
include:
- master
paths:
exclude: ["doc", "*.md", ".appveyor.yml", ".travis.yml"]
exclude: ["doc", "*.md"]

variables:
# TreatWarningsAsErrors: true
Expand All @@ -12,14 +13,19 @@ variables:

jobs:
- job: Windows
pool: Hosted VS2017
pool: Hosted Windows 2019 with VS2019
steps:
- script: |
dotnet tool install --tool-path . nbgv
.\nbgv cloud -p src
displayName: Set build number
condition: ne(variables['system.pullrequest.isfork'], true)
- task: UseDotNet@2
displayName: Install .NET Core SDK
inputs:
version: 2.2.401

- script: dotnet --info
displayName: Show dotnet SDK info

Expand All @@ -35,7 +41,7 @@ jobs:
# Use VSBuild on Windows so GitLink will work (it fails on dotnet build)
- task: VSBuild@1
inputs:
vsVersion: 15.0
vsVersion: "16.0"
msbuildArgs: /t:build,pack /m /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
platform: $(BuildPlatform)
configuration: $(BuildConfiguration)
Expand Down
16 changes: 9 additions & 7 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<Project>
<PropertyGroup>
<CodeGenerationRoslynVersion>0.4.88</CodeGenerationRoslynVersion>
<CodeGenerationRoslynVersion>0.6.1</CodeGenerationRoslynVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Update="CodeGeneration.Roslyn.Attributes" Version="$(CodeGenerationRoslynVersion)" />
<PackageReference Update="CodeGeneration.Roslyn" Version="$(CodeGenerationRoslynVersion)" />
<PackageReference Update="CodeGeneration.Roslyn.BuildTime" Version="$(CodeGenerationRoslynVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.9.0" />
<PackageReference Update="CodeGeneration.Roslyn" Version="$(CodeGenerationRoslynVersion)" />
<PackageReference Update="CodeGeneration.Roslyn.Engine" Version="$(CodeGenerationRoslynVersion)" />
<PackageReference Update="Microsoft.Build" Version="14.3.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.1.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Update="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Update="System.Diagnostics.Contracts" Version="4.3.0" />
<PackageReference Update="Validation" Version="2.4.18" />
<PackageReference Update="Microsoft.Build" Version="14.3.0" />
<PackageReference Update="xunit" Version="2.3.1" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Update="Validation" Version="2.4.22" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Update="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Update="dotnet-codegen" Version="$(CodeGenerationRoslynVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[AttributeUsage(AttributeTargets.Class)]
[Conditional("CodeGeneration")]
[CodeGenerationAttribute("ImmutableObjectGraph.Generation.CodeGenerator, ImmutableObjectGraph.Generation, Version=" + ThisAssembly.AssemblyVersion + ", Culture=neutral, PublicKeyToken=bfd91f1bd601e0d7")]
[CodeGenerationAttribute("ImmutableObjectGraph.Generation.CodeGenerator, ImmutableObjectGraph.Generation, Version=" + ThisAssembly.AssemblyVersion + ", Culture=neutral, PublicKeyToken=" + ThisAssembly.PublicKeyToken)]
public class GenerateImmutableAttribute : Attribute
{
public GenerateImmutableAttribute()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>ImmutableObjectGraph.Generation</RootNamespace>
<TargetFrameworks>netstandard1.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Description>The runtime components behind the types generated with the ImmutableObjectGraph.Generation package.</Description>

<!-- This gets included in ImmutableObjectGraph.Generation -->
Expand Down
12 changes: 7 additions & 5 deletions src/ImmutableObjectGraph.Generation.Tests/CodeGenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CodeGeneration.Roslyn.Engine;
using global::CodeGeneration.Roslyn;
using ImmutableObjectGraph.Generation.Roslyn;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
Expand All @@ -34,8 +36,7 @@ public CodeGenTests(ITestOutputHelper logger)
var workspace = new AdhocWorkspace();
var project = workspace.CurrentSolution.AddProject("test", "test", "C#")
.WithCompilationOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
.AddMetadataReferences(GetReferences("Profile78"))
.AddMetadataReference(MetadataReference.CreateFromFile(Assembly.Load("netstandard, Version=2.0.0.0").Location))
.AddMetadataReferences(GetNetStandard20References())
.AddMetadataReference(MetadataReference.CreateFromFile(typeof(GenerateImmutableAttribute).Assembly.Location))
.AddMetadataReference(MetadataReference.CreateFromFile(typeof(CodeGenerationAttributeAttribute).Assembly.Location))
.AddMetadataReference(MetadataReference.CreateFromFile(typeof(Optional).Assembly.Location))
Expand Down Expand Up @@ -335,10 +336,11 @@ private static string EscapeLineEndingCharacters(string whitespace)
return builder.ToString();
}

private static IEnumerable<MetadataReference> GetReferences(string profile)
private static IEnumerable<MetadataReference> GetNetStandard20References()
{
string profileDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile", profile);
foreach (string assembly in Directory.GetFiles(profileDirectory, "*.dll"))
string nugetPackageRoot = Environment.GetEnvironmentVariable("NUGET_PACKAGES") ?? Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\.nuget\packages");
string netstandardRoot = Path.Combine(nugetPackageRoot, @"netstandard.library\2.0.3\build\netstandard2.0\ref");
foreach (string assembly in Directory.GetFiles(netstandardRoot, "*.dll"))
{
yield return MetadataReference.CreateFromFile(assembly);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Update="TestSources\AbstractClassMidTypeHierarchyWithRequiredField.cs">
Expand Down Expand Up @@ -82,10 +79,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" />
<PackageReference Include="Validation" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="CodeGeneration.Roslyn" PrivateAssets="all" />
<PackageReference Include="CodeGeneration.Roslyn.Engine" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-codegen" />
Expand All @@ -95,4 +95,4 @@
<ProjectReference Include="..\ImmutableObjectGraph.Generation\ImmutableObjectGraph.Generation.csproj" />
<ProjectReference Include="..\ImmutableObjectGraph\ImmutableObjectGraph.csproj" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/ImmutableObjectGraph.Generation/CodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Threading;
using System.Threading.Tasks;
using global::CodeGeneration.Roslyn;
using ImmutableObjectGraph.Generation.Roslyn;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>ImmutableObjectGraph.Generation</RootNamespace>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>MSBuild-based code generator to transform simple mutable type definitions into fully functional immutable types with persistent characteristics.</Description>

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down Expand Up @@ -36,6 +36,7 @@
<PackageReference Include="CodeGeneration.Roslyn" PrivateAssets="all" />
<PackageReference Include="CodeGeneration.Roslyn.BuildTime" PrivateAssets="none" />
<PackageReference Include="System.Diagnostics.Contracts" PrivateAssets="all" />
<PackageReference Include="Validation" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-codegen" />
Expand All @@ -57,4 +58,4 @@
<NuspecProperties>id=$(PackageId);version=$(NuGetPackageVersion);authors=$(Authors);copyright=$(Copyright);tags=$(PackageTags);requireLicenseAcceptance=$(PackageRequireLicenseAcceptance);licenseUrl=$(PackageLicenseUrl);description=$(Description);CodeGenerationRoslynVersion=$(CodeGenerationRoslynVersion);Configuration=$(Configuration);OutDir=$(OutDir)</NuspecProperties>
</PropertyGroup>
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<copyright>$Copyright$</copyright>
<tags>$PackageTags$</tags>
<dependencies>
<group targetFramework=".NETStandard1.0">
<group targetFramework=".NETStandard2.0">
<dependency id="CodeGeneration.Roslyn.BuildTime" version="$CodeGenerationRoslynVersion$" />
<dependency id="ImmutableObjectGraph" version="$version$" />
</group>
Expand All @@ -25,6 +25,6 @@
<file src="..\..\lib\netstandard1.0\CG.Pluralization.dll" target="tools\" />
<file src="Readme.txt" target="Readme.txt" />
<file src="build\*" target="build\" />
<file src="..\..\bin\ImmutableObjectGraph.Generation.Attributes\$Configuration$\netstandard1.0\ImmutableObjectGraph.Generation.Attributes.dll" target="lib\netstandard1.0\" />
<file src="..\..\bin\ImmutableObjectGraph.Generation.Attributes\$Configuration$\netstandard2.0\ImmutableObjectGraph.Generation.Attributes.dll" target="lib\netstandard2.0\" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ImmutableObjectGraph.Generation.Roslyn
{
internal class CSharpDeclarationComputer : DeclarationComputer
public class CSharpDeclarationComputer : DeclarationComputer
{
public static ImmutableArray<DeclarationInfo> GetDeclarationsInSpan(SemanticModel model, TextSpan span, bool getSymbol, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ImmutableObjectGraph.Generation.Roslyn
using System.Threading;
using Microsoft.CodeAnalysis;

internal class DeclarationComputer
public class DeclarationComputer
{
internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNode node, bool getSymbol, IEnumerable<SyntaxNode> executableCodeBlocks, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ImmutableObjectGraph.Generation.Roslyn
/// <summary>
/// Struct containing information about a source declaration.
/// </summary>
internal struct DeclarationInfo
public struct DeclarationInfo
{
private readonly SyntaxNode _declaredNode;
private readonly ImmutableArray<SyntaxNode> _executableCodeBlocks;
Expand Down
1 change: 1 addition & 0 deletions src/ImmutableObjectGraph.Generation/Syntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ImmutableObjectGraph.Generation.Roslyn;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
4 changes: 2 additions & 2 deletions src/ImmutableObjectGraph/ImmutableObjectGraph.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="MSBuild.Sdk.Extras">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Validation" PrivateAssets="compile" />
Expand Down
2 changes: 1 addition & 1 deletion src/RoslynDemo/RoslynDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net472</TargetFramework>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
5 changes: 1 addition & 4 deletions src/global.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"sdk": {
"version": "2.1.402"
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "1.5.4"
"version": "2.2.401"
}
}

0 comments on commit c4e14bd

Please sign in to comment.