Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show type and member names in warning messages #195

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dscom/writer/ElemDescBasedWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public virtual void ReportEvent()

if (Type.GetUnderlayingType().IsGenericType)
{
Context.LogWarning("Warning: Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM.", unchecked(HRESULT.TLBX_E_GENERICINST_SIGNATURE));
Context.LogWarning($"Warning: Type library exporter encountered generic type {Type.GetUnderlayingType()} in a signature while writing type {ParentType}. Generic code may not be exported to COM.", unchecked(HRESULT.TLBX_E_GENERICINST_SIGNATURE));
}

var unrefedType = Type.IsByRef ? Type.GetElementType()! : Type;
Expand All @@ -62,7 +62,7 @@ public virtual void ReportEvent()
marshasinfo += $" SafeArraySubType: {TypeProvider.MarshalAsAttribute!.SafeArraySubType}";
}
}
Context.LogWarning($"Type library exporter warning processing '{Type.Name}'{marshasinfo}. Warning: The method or field has an invalid managed/unmanaged type combination, check the MarshalAs directive.", unchecked(HRESULT.TLBX_E_BAD_NATIVETYPE));
Context.LogWarning($"Type library exporter warning processing '{Type}'{marshasinfo}. Warning: The method or field has an invalid managed/unmanaged type combination, check the MarshalAs directive.", unchecked(HRESULT.TLBX_E_BAD_NATIVETYPE));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/dscom/writer/EnumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public override void Create()
varDesc.wVarFlags = 0;

TypeInfo.AddVarDesc(index, varDesc)
.ThrowIfFailed($"Failed to add variable description for enum {Name}.");
.ThrowIfFailed($"Failed to add variable description for enum {SourceType}.");
TypeInfo.SetVarName(index, Context.NameResolver.GetMappedName(field, $"{Name}_{field.Name}"))
.ThrowIfFailed($"Failed to set variable name for enum {Name}.");
.ThrowIfFailed($"Failed to set variable name {field.Name} for enum {SourceType}.");
index++;
}

Expand Down
8 changes: 4 additions & 4 deletions src/dscom/writer/MethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,23 @@ public override void Create()
names = GetNamesForParameters().ToArray();

typeInfo.AddFuncDesc((uint)funcIndex, funcDesc.Value)
.ThrowIfFailed($"Failed to add function description for {MethodInfo.Name}.");
.ThrowIfFailed($"Failed to add function description for {MethodInfo.DeclaringType}.{MethodInfo.Name}().");

typeInfo.SetFuncAndParamNames((uint)funcIndex, names, (uint)names.Length)
.ThrowIfFailed($"Failed to set function and parameter names for {MethodInfo.Name}.");
.ThrowIfFailed($"Failed to set function and parameter names for {MethodInfo.DeclaringType}.{MethodInfo.Name}().");

var description = MethodInfo.GetCustomAttribute<System.ComponentModel.DescriptionAttribute>();
if (description != null)
{
typeInfo.SetFuncDocString((uint)funcIndex, description.Description)
.ThrowIfFailed($"Failed to set function documentation string for {MethodInfo.Name}.");
.ThrowIfFailed($"Failed to set function documentation string for {MethodInfo.DeclaringType}.{MethodInfo.Name}().");
}

if (memidCreated == 0 && InvokeKind == INVOKEKIND.INVOKE_FUNC)
{
//Function has been forced as property (default member handling)
typeInfo.SetFuncCustData((uint)funcIndex, new Guid(Guids.GUID_Function2Getter), 1)
.ThrowIfFailed($"Failed to set function custom data for {MethodInfo.Name}.");
.ThrowIfFailed($"Failed to set function custom data for {MethodInfo.DeclaringType}.{MethodInfo.Name}().");
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/dscom/writer/ParameterWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override void ReportEvent()
base.ReportEvent();
if (!ParameterIsResolvable && Type.GetUnderlayingType().IsInterface)
{
Context.LogWarning($"Warning: Type library exporter could not find the type library for {Type.GetUnderlayingType().Name}. IUnknown was substituted for the interface.", HRESULT.TLBX_I_USEIUNKNOWN);
Context.LogWarning($"Warning: Type library exporter could not find the type library for {Type.GetUnderlayingType()} while writing member {ParentType}.{ParameterInfo.Member.Name}. IUnknown was substituted for the interface.", HRESULT.TLBX_I_USEIUNKNOWN);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dscom/writer/TypeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public virtual void CreateTypeInfo()
if (typeLib != null)
{
typeLib.CreateTypeInfo(Context.NameResolver.GetMappedName(SourceType, Name), TypeKind, out var createTypeInfo)
.ThrowIfFailed($"Failed to create type info for {Name}.");
.ThrowIfFailed($"Failed to create type info {Name} for type {SourceType}.");

_createTypeInfo2 = (ICreateTypeInfo2)createTypeInfo;

Expand Down
Loading