Skip to content

Commit

Permalink
Merge pull request #30 from sharwell/polish
Browse files Browse the repository at this point in the history
Polish from user reports
  • Loading branch information
sharwell authored Sep 30, 2019
2 parents 42b5385 + ff64d81 commit 0bf68ed
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dotnet_code_quality_unused_parameters = all:suggestion

# var preferences
csharp_style_var_elsewhere = false:silent
csharp_style_var_for_built_in_types = false:none
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = true:silent

# Expression-bodied members
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
<!-- Enable nullable reference types -->
<PropertyGroup>
<Nullable>enable</Nullable>
<AnnotatedReferenceAssemblyVersion>3.0.0-preview9-19423-09</AnnotatedReferenceAssemblyVersion>
<AnnotatedReferenceAssemblyVersion>3.0.0</AnnotatedReferenceAssemblyVersion>
<GenerateNullableAttributes>false</GenerateNullableAttributes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.31" PrivateAssets="all" />
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.53" PrivateAssets="all" />
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(AnnotatedReferenceAssemblyVersion)]" />
</ItemGroup>

Expand Down
10 changes: 0 additions & 10 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<Choose>
<When Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<ItemGroup>
<UnannotatedReferenceAssembly Include="System" />
<UnannotatedReferenceAssembly Include="System.Core" />
</ItemGroup>
</When>
</Choose>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public ITaskItem[]? GeneratedAssemblies

public override bool Execute()
{
var unannotatedReferenceAssembly = TargetFrameworkDirectories.Select(path => Path.Combine(path.ItemSpec, UnannotatedReferenceAssembly + ".dll")).FirstOrDefault(File.Exists);
var annotatedReferenceAssembly = Path.Combine(AnnotatedReferenceAssemblyDirectory, UnannotatedReferenceAssembly + ".dll");
string unannotatedReferenceAssembly = TargetFrameworkDirectories.Select(path => Path.Combine(path.ItemSpec, UnannotatedReferenceAssembly + ".dll")).FirstOrDefault(File.Exists);
string annotatedReferenceAssembly = Path.Combine(AnnotatedReferenceAssemblyDirectory, UnannotatedReferenceAssembly + ".dll");
bool foundAnnotatedAssembly = File.Exists(annotatedReferenceAssembly);

Log.LogMessage($"Generating reference assembly for {UnannotatedReferenceAssembly}");
Expand All @@ -79,7 +79,7 @@ public override bool Execute()
}

Directory.CreateDirectory(OutputPath);
var outputAssembly = Path.Combine(OutputPath, Path.GetFileName(unannotatedReferenceAssembly));
string outputAssembly = Path.Combine(OutputPath, Path.GetFileName(unannotatedReferenceAssembly));
Program.Main(Log, unannotatedReferenceAssembly, annotatedReferenceAssembly, outputAssembly);
GeneratedAssemblies = new[] { new TaskItem(outputAssembly) };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,12 @@ public CustomAttribute AttributeUsage(AttributeTargets validOn, bool? allowMulti

return customAttribute;
}

public CustomAttribute ReferenceAssembly()
{
MethodDefinition constructor = _wellKnownTypes.SystemRuntimeCompilerServicesReferenceAssemblyAttribute.Resolve().Methods.Single(method => method.IsConstructor && !method.IsStatic && method.Parameters.Count == 0);
var customAttribute = new CustomAttribute(_wellKnownTypes.Module.ImportReference(constructor));
return customAttribute;
}
}
}
8 changes: 4 additions & 4 deletions TunnelVisionLabs.ReferenceAssemblyAnnotator/MethodFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace TunnelVisionLabs.ReferenceAssemblyAnnotator

internal static class MethodFactory
{
public static MethodDefinition DefaultConstructor(WellKnownTypes wellKnownTypes)
=> Constructor(wellKnownTypes);
public static MethodDefinition DefaultConstructor(TypeSystem typeSystem)
=> Constructor(typeSystem);

public static MethodDefinition Constructor(WellKnownTypes wellKnownTypes)
public static MethodDefinition Constructor(TypeSystem typeSystem)
{
var constructor = new MethodDefinition(".ctor", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, wellKnownTypes.TypeSystem.Void);
var constructor = new MethodDefinition(".ctor", MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, typeSystem.Void);
constructor.Body = new MethodBody(constructor)
{
Instructions =
Expand Down
Loading

0 comments on commit 0bf68ed

Please sign in to comment.