Skip to content

Commit b86df1c

Browse files
authored
Updated to use C#7.2 to leverage updated language features. (#39)
Future updates will further leverage the private protected
1 parent f012b0c commit b86df1c

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/Llvm.NET/Llvm.NET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<Description>.NET Bindings for LLVM</Description>
1414
<PackageTags>LLVM,Compiler,JIT</PackageTags>
1515
<NoPackageAnalysis>true</NoPackageAnalysis>
16-
<LangVersion>7.1</LangVersion>
16+
<LangVersion>7.2</LangVersion>
1717
</PropertyGroup>
1818
<ItemGroup>
1919
<Compile Remove="obj\**" />

src/Llvm.NET/Metadata/LlvmMetadata.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,25 @@ public override string ToString( )
4646

4747
internal LLVMMetadataRef MetadataHandle { get; /*protected*/ set; }
4848

49-
// ideally this would be protected AND internal but C#
50-
// doesn't have any syntax to allow such a thing on a constructor
51-
// so it is internal and internal code should ensure it is
52-
// only ever used by derived type constructors
53-
/*protected*/ internal LlvmMetadata( LLVMMetadataRef handle )
49+
internal static T FromHandle<T>( Context context, LLVMMetadataRef handle )
50+
where T : LlvmMetadata
5451
{
5552
if( handle == default )
5653
{
57-
throw new ArgumentNullException( nameof( handle ) );
54+
return null;
5855
}
5956

60-
MetadataHandle = handle;
57+
return ( T )context.GetNodeFor( handle, StaticFactory );
6158
}
6259

63-
internal static T FromHandle<T>( Context context, LLVMMetadataRef handle )
64-
where T : LlvmMetadata
60+
private protected LlvmMetadata( LLVMMetadataRef handle )
6561
{
6662
if( handle == default )
6763
{
68-
return null;
64+
throw new ArgumentNullException( nameof( handle ) );
6965
}
7066

71-
return ( T )context.GetNodeFor( handle, StaticFactory );
67+
MetadataHandle = handle;
7268
}
7369

7470
/// <summary>Enumeration to define debug information metadata nodes</summary>

0 commit comments

Comments
 (0)