diff --git a/src/Ubiquity.NET.Llvm.Tests/DebugInfo/DebugStructTypeTests.cs b/src/Ubiquity.NET.Llvm.Tests/DebugInfo/DebugStructTypeTests.cs index def30ef20..53302efe9 100644 --- a/src/Ubiquity.NET.Llvm.Tests/DebugInfo/DebugStructTypeTests.cs +++ b/src/Ubiquity.NET.Llvm.Tests/DebugInfo/DebugStructTypeTests.cs @@ -9,6 +9,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Ubiquity.NET.Llvm.DebugInfo; +using Ubiquity.NET.Llvm.Types; namespace Ubiquity.NET.Llvm.Tests.DebugInfo { @@ -65,21 +66,34 @@ public void DebugStructType_constructing_empty_anonymous_struct_succeeds( ) Assert.AreEqual( sourceName, structType.SourceName ); } -#if NOT_YET_READY_GENERATED [TestMethod] - public void SetBody_StateUnderTest_ExpectedBehavior( ) + public void SetBody_with_native_elements_succeeds( ) { - var debugStructType = new DebugStructType( TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO ); + using var context = new Context( ); + using var testModule = context.CreateBitcodeModule( "test" ); + + var file = testModule.DIBuilder.CreateFile( "test.foo" ); + uint line = 1234; + string sourceName = string.Empty; + string linkageName = string.Empty; + + var debugStructType = new DebugStructType( testModule, linkageName, file, sourceName, file, line ); bool packed = false; - ITypeRef[ ] elements = null; + var elements = new ITypeRef[] { context.Float128Type, context.Int32Type, context.Int64Type }; debugStructType.SetBody( packed, elements ); - Assert.Inconclusive( ); + Assert.AreEqual( elements.Length, debugStructType.Members.Count ); + for(int i =0; i < elements.Length; ++i ) + { + Assert.AreSame( elements[ i ], debugStructType.Members[ i ] ); + } } +#if NOT_YET_READY_GENERATED + [TestMethod] public void SetBody_StateUnderTest_ExpectedBehavior1( ) { diff --git a/src/Ubiquity.NET.Llvm/Context.cs b/src/Ubiquity.NET.Llvm/Context.cs index e8f331ff2..c9c2655eb 100644 --- a/src/Ubiquity.NET.Llvm/Context.cs +++ b/src/Ubiquity.NET.Llvm/Context.cs @@ -396,7 +396,7 @@ public Constant CreateNamedConstantStruct( IStructType type, IEnumerableCreate an opaque structure type (e.g. a forward reference) - /// Name of the type + /// Name of the type (use for anonymous types) /// /// This method creates an opaque type. The /// method provides a means to add a body, including indication of packed status, to an opaque @@ -406,7 +406,7 @@ public Constant CreateNamedConstantStruct( IStructType type, IEnumerableNew type public IStructType CreateStructType( string name ) { - name.ValidateNotNullOrWhiteSpace( nameof( name ) ); + name.ValidateNotNull( nameof( name ) ); var handle = LLVMStructCreateNamed( ContextHandle, name ); return TypeRef.FromHandle( handle.ThrowIfInvalid( ) )!; } diff --git a/src/Ubiquity.NET.Llvm/IOperandCollection.cs b/src/Ubiquity.NET.Llvm/IOperandCollection.cs index 536060cf8..1bdd1357b 100644 --- a/src/Ubiquity.NET.Llvm/IOperandCollection.cs +++ b/src/Ubiquity.NET.Llvm/IOperandCollection.cs @@ -33,10 +33,10 @@ public interface IOperandCollection bool Contains( T item ); /// Creates a slice of the collection - /// inclusive start index for the slice + /// Inclusive start index for the slice /// Exclusive end index for the slice /// Slice of the collection - [SuppressMessage( "Naming", "CA1716:Identifiers should not match keywords", Justification = "Name is consistent with System.Range parameters" )] + [SuppressMessage( "Naming", "CA1716:Identifiers should not match keywords", Justification = "Naming is consistent with System.Range parameters" )] IOperandCollection Slice( int start, int end ) { return new OperandCollectionSlice( this, new Range( start, end ) ); diff --git a/src/Ubiquity.NET.Llvm/IOperandContainer.cs b/src/Ubiquity.NET.Llvm/IOperandContainer.cs deleted file mode 100644 index adfce4f9c..000000000 --- a/src/Ubiquity.NET.Llvm/IOperandContainer.cs +++ /dev/null @@ -1,43 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Ubiquity.NET Contributors. All rights reserved. -// -// ----------------------------------------------------------------------- - -/* -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Ubiquity.NET.Llvm -{ - /// Internal interface to provide raw access to operands of a container type - /// type of operands - /// - /// This is used to build an operand list for multiple container types that is ultimately - /// exposed as a public property on the container. - /// - internal interface IOperandContainer - where T : class - { - /// Gets the count of operands in the container - long Count { get; } - - /// Gets an operand from the container - /// Raw index of the operand in the container - /// Operand from the container - TItem? GetRawOperandAt( int index ) - where TItem : class, T; - - /// Sets an operand in the container - /// Raw index of the operand in the container - /// Value to set at the index - void SetRawOperandAt( int index, T? value ); - - /// Adds an item to the end of the container (i.e. append) - /// item to add - /// If the container doesn't support adding items - /// If the container doesn't support adding null items - void Add( T? item ); - } -} -*/