diff --git a/eng/generators.targets b/eng/generators.targets
index a83febbe2c8bea..92909989d30426 100644
--- a/eng/generators.targets
+++ b/eng/generators.targets
@@ -13,7 +13,7 @@
@@ -22,7 +22,7 @@
'$(IsSourceProject)' == 'true' and
'$(MSBuildProjectExtension)' == '.csproj' and
(
- '$(TargetFrameworkMoniker)' != '$(NetCoreAppCurrentTargetFrameworkMoniker)' or
+ !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or
(
'$(DisableImplicitFrameworkReferences)' == 'true' and
(
@@ -33,17 +33,13 @@
)" />
diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs
index 2b8b4e12ad58a2..4d4a9f20dc2c43 100644
--- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs
+++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/BaseJSGenerator.cs
@@ -26,7 +26,7 @@ protected BaseJSGenerator(MarshalerType marshalerType, IMarshallingGenerator inn
public virtual bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => _inner.UsesNativeIdentifier(info, context);
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => _inner.GetNativeSignatureBehavior(info);
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => _inner.GetValueBoundaryBehavior(info, context);
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => _inner.SupportsByValueMarshalKind(marshalKind, context);
public virtual IEnumerable GenerateBind(TypePositionInfo info, StubCodeContext context)
{
diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs
index 1a50568a1fc444..37204d1f7464d1 100644
--- a/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs
+++ b/src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/Marshaling/EmptyJSGenerator.cs
@@ -15,7 +15,7 @@ internal sealed class EmptyJSGenerator : IJSMarshallingGenerator
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.ManagedTypeAndAttributes;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => false;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs
index 9864fbed576ec5..c676f27cb9f401 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/DiagnosticDescriptorProvider.cs
@@ -24,6 +24,8 @@ internal sealed class DiagnosticDescriptorProvider : IDiagnosticDescriptorProvid
GeneratorDiagnostic.NotSupported { NotSupportedDetails: null, TypePositionInfo: { IsManagedReturnPosition: false, MarshallingAttributeInfo: MarshalAsInfo } } => GeneratorDiagnostics.MarshalAsParameterConfigurationNotSupported,
GeneratorDiagnostic.NotSupported { NotSupportedDetails: not null, TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.ReturnTypeNotSupportedWithDetails,
GeneratorDiagnostic.NotSupported { NotSupportedDetails: not null, TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails,
+ GeneratorDiagnostic.UnnecessaryData { TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.UnnecessaryParameterMarshallingInfo,
+ GeneratorDiagnostic.UnnecessaryData { TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.UnnecessaryReturnMarshallingInfo,
{ IsFatal: false } => null,
{ TypePositionInfo.IsManagedReturnPosition: true } => GeneratorDiagnostics.ReturnTypeNotSupported,
{ TypePositionInfo.IsManagedReturnPosition: false } => GeneratorDiagnostics.ParameterTypeNotSupported,
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs
index 9aaf3a59d0a4a7..fb941b73d08141 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/GeneratorDiagnostics.cs
@@ -21,6 +21,7 @@ public class Ids
public const string TypeNotSupported = Prefix + "1051";
public const string ConfigurationNotSupported = Prefix + "1052";
public const string RequiresAllowUnsafeBlocks = Prefix + "1062";
+ public const string UnnecessaryMarshallingInfo = Prefix + "1063";
public const string InvalidGeneratedComInterfaceAttributeUsage = Prefix + "1090";
public const string MemberWillNotBeSourceGenerated = Prefix + "1091";
public const string MultipleComInterfaceBaseTypes = Prefix + "1092";
@@ -415,6 +416,34 @@ public class Ids
isEnabledByDefault: true,
description: GetResourceString(nameof(SR.ClassDoesNotImplementAnyGeneratedComInterfacesDescription)));
+ public static readonly DiagnosticDescriptor UnnecessaryParameterMarshallingInfo =
+ new DiagnosticDescriptor(
+ Ids.UnnecessaryMarshallingInfo,
+ GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
+ GetResourceString(nameof(SR.UnnecessaryParameterMarshallingInfoMessage)),
+ Category,
+ DiagnosticSeverity.Info,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(SR.UnnecessaryMarshallingInfoDescription)),
+ customTags: new[]
+ {
+ WellKnownDiagnosticTags.Unnecessary
+ });
+
+ public static readonly DiagnosticDescriptor UnnecessaryReturnMarshallingInfo =
+ new DiagnosticDescriptor(
+ Ids.UnnecessaryMarshallingInfo,
+ GetResourceString(nameof(SR.UnnecessaryMarshallingInfoTitle)),
+ GetResourceString(nameof(SR.UnnecessaryReturnMarshallingInfoMessage)),
+ Category,
+ DiagnosticSeverity.Info,
+ isEnabledByDefault: true,
+ description: GetResourceString(nameof(SR.UnnecessaryMarshallingInfoDescription)),
+ customTags: new[]
+ {
+ WellKnownDiagnosticTags.Unnecessary
+ });
+
///
/// Report diagnostic for invalid configuration for string marshalling.
///
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs
index be71ae535f1c94..9373dd7eaa4b9a 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ComInterfaceDispatchMarshallerFactory.cs
@@ -61,7 +61,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.NativeIdentifier;
public bool IsSupported(TargetFramework target, Version version)
=> target == TargetFramework.Net && version >= new Version(5, 0);
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs
index 4c012042a05791..13d82b4a332197 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ManagedHResultExceptionMarshallerFactory.cs
@@ -71,7 +71,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.NativeType;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
@@ -108,7 +108,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.NativeType;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.ManagedIdentifier;
public bool IsSupported(TargetFramework target, Version version) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => false;
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs
index b5a2d998890e8a..ba55a49c1a7c94 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Marshallers/ObjectUnwrapperMarshallerFactory.cs
@@ -61,7 +61,7 @@ public IEnumerable Generate(TypePositionInfo info, StubCodeCont
public SignatureBehavior GetNativeSignatureBehavior(TypePositionInfo info) => SignatureBehavior.NativeType;
public ValueBoundaryBehavior GetValueBoundaryBehavior(TypePositionInfo info, StubCodeContext context) => ValueBoundaryBehavior.NativeIdentifier;
public bool IsSupported(TargetFramework target, Version version) => true;
- public bool SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => false;
+ public ByValueMarshalKindSupport SupportsByValueMarshalKind(ByValueContentsMarshalKind marshalKind, StubCodeContext context) => ByValueMarshalKindSupport.NotSupported;
public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context) => true;
}
}
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx
index 420d0a0616b003..2d66fc739503bf 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/Strings.resx
@@ -395,4 +395,16 @@
The specified 'MarshalAsAttribute' configuration for the return value of method '{1}' is not supported by source-generated COM. If the specified configuration is required, use `ComImport` instead.
+
+ Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.
+
+
+ Unnecessary marshalling info was provided and can be removed.
+
+
+ Unnecessary marshalling info '{0}' was provided for parameter '{1}'
+
+
+ Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'
+
diff --git a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf
index fe85bbe4a1f12d..aeb5da741e491a 100644
--- a/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf
+++ b/src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Resources/xlf/Strings.cs.xlf
@@ -454,6 +454,26 @@
Zadaný typ není podporován modelem COM generovaným zdrojem.
+
+ Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.
+ Unnecesssary marshalling info was provided. This marshalling information can be removed without any change in behavior to the application.
+
+
+
+ Unnecessary marshalling info was provided and can be removed.
+ Unnecessary marshalling info was provided and can be removed.
+
+
+
+ Unnecessary marshalling info '{0}' was provided for parameter '{1}'
+ Unnecessary marshalling info '{0}' was provided for parameter '{1}'
+
+
+
+ Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'
+ Unnecessary marshalling info '{0}' was provided for the return type of method '{1}'
+
+