Skip to content

Commit

Permalink
Revert "Remove CLSCompliant attribute (#12469)"
Browse files Browse the repository at this point in the history
This reverts commit f7a5332.

Didn't realize the impact this would have upstream if dependencies were
building as CLSCompliant.
  • Loading branch information
JeremyKuhne committed Nov 14, 2024
1 parent 8dd924a commit e30751e
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 60 deletions.
5 changes: 1 addition & 4 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
<Import Project="$(RepositoryEngineeringDir)Analyzer.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="$(RepositoryEngineeringDir)packageContent.targets" />
<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
<Import Project="$(RepositoryEngineeringDir)Test.targets" Condition="'$(IsTestProject)' == 'true' "/>

<PropertyGroup>
<Description Condition="'$(Description)' == ''">$(AssemblyName)</Description>
</PropertyGroup>

<!-- CA1416 Validate platform compatibility. Do not apply to netstandard as it does not have the attribute. -->
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform" Condition="!$(TargetFramework.StartsWith('netstandard'))">
Expand Down
35 changes: 35 additions & 0 deletions eng/versioning.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GenerateAssemblyInfo Condition="'$(GenerateAssemblyInfo)'==''">true</GenerateAssemblyInfo>
</PropertyGroup>

<PropertyGroup Condition="'$(GenerateAssemblyInfo)'=='true'">
<AssemblyInfoFile Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)_AssemblyInfo.g.cs</AssemblyInfoFile>
</PropertyGroup>

<PropertyGroup>
<Description Condition="'$(Description)' == ''">$(AssemblyName)</Description>
</PropertyGroup>

<!-- Note: ReferenceAssemblies.targets still uses @(AssemblyInfoLines) as well. So if you remove this, those need to migrate too. -->
<Target Name="_WriteNonStringAssemblyInfoAttributes"
AfterTargets="CoreGenerateAssemblyInfo"
Inputs="$(MSBuildProjectFile)"
Outputs="$(AssemblyInfoFile)">

<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<AssemblyInfoLines Condition="'$(CLSCompliant)'=='true'" Include="[assembly:System.CLSCompliant(true)]" />
<AssemblyInfoLines Condition="'$(CLSCompliant)'=='false'" Include="[assembly:System.CLSCompliant(false)]" />
</ItemGroup>

<WriteLinesToFile File="$(AssemblyInfoFile)"
Lines="@(AssemblyInfoLines)"
Condition="'@(AssemblyInfoLines)' != ''"
Overwrite="true" />

<ItemGroup Condition="'@(AssemblyInfoLines)' != ''">
<Compile Include="$(AssemblyInfoFile)" />
<FileWrites Include="$(AssemblyInfoFile)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Namespace Microsoft.VisualBasic.Devices
''' <exception cref="ComponentModel.Win32Exception">
''' Throw if we are unable to obtain the memory status.
''' </exception>
<CLSCompliant(False)>
Public ReadOnly Property AvailablePhysicalMemory() As UInt64
Get
Return MemoryStatus.AvailablePhysicalMemory
Expand All @@ -63,6 +64,7 @@ Namespace Microsoft.VisualBasic.Devices
''' <exception cref="ComponentModel.Win32Exception">
''' Throw if we are unable to obtain the memory status.
''' </exception>
<CLSCompliant(False)>
Public ReadOnly Property AvailableVirtualMemory() As UInt64
Get
Return MemoryStatus.AvailableVirtualMemory
Expand Down Expand Up @@ -129,6 +131,7 @@ Namespace Microsoft.VisualBasic.Devices
''' <exception cref="ComponentModel.Win32Exception">
''' Throw if we are unable to obtain the memory status.
''' </exception>
<CLSCompliant(False)>
Public ReadOnly Property TotalPhysicalMemory() As UInt64
Get
Return MemoryStatus.TotalPhysicalMemory
Expand All @@ -145,6 +148,7 @@ Namespace Microsoft.VisualBasic.Devices
''' <exception cref="ComponentModel.Win32Exception">
''' Throw if we are unable to obtain the memory status.
''' </exception>
<CLSCompliant(False)>
Public ReadOnly Property TotalVirtualMemory() As UInt64
Get
Return MemoryStatus.TotalVirtualMemory
Expand Down
44 changes: 1 addition & 43 deletions src/System.Drawing.Common/src/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
Expand All @@ -25,34 +25,13 @@
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>M:System.Drawing.Imaging.ColorMatrix.#ctor(System.Single[][]):[T:System.CLSCompliantAttribute]</Target>
<Left>lib/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>M:System.Drawing.Printing.PrintPageEventArgs.get_Graphics:[T:System.Runtime.CompilerServices.NullableContextAttribute]</Target>
<Left>lib/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>P:System.Drawing.Imaging.ImageCodecInfo.SignatureMasks:[T:System.CLSCompliantAttribute]</Target>
<Left>lib/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>P:System.Drawing.Imaging.ImageCodecInfo.SignaturePatterns:[T:System.CLSCompliantAttribute]</Target>
<Left>lib/net8.0/System.Drawing.Common.dll</Left>
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>P:System.Drawing.Printing.PrintPageEventArgs.Graphics:[T:System.Runtime.CompilerServices.NullableAttribute]</Target>
Expand Down Expand Up @@ -144,27 +123,6 @@
<Right>lib/net8.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>M:System.Drawing.Imaging.ColorMatrix.#ctor(System.Single[][]):[T:System.CLSCompliantAttribute]</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/netstandard2.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>P:System.Drawing.Imaging.ImageCodecInfo.SignatureMasks:[T:System.CLSCompliantAttribute]</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/netstandard2.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0014</DiagnosticId>
<Target>P:System.Drawing.Imaging.ImageCodecInfo.SignaturePatterns:[T:System.CLSCompliantAttribute]</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/netstandard2.0/System.Drawing.Common.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0015</DiagnosticId>
<Target>T:System.Drawing.Printing.PrintPageEventArgs:[T:System.Runtime.CompilerServices.NullableContextAttribute]</Target>
Expand Down
3 changes: 3 additions & 0 deletions src/System.Drawing.Common/src/Special/NotSupported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,7 @@ public enum ColorMapType
public sealed partial class ColorMatrix
{
public ColorMatrix() { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); }
[System.CLSCompliantAttribute(false)]
public ColorMatrix(float[][] newColorMatrix) { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); }
public float this[int row, int column] { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
public float Matrix00 { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
Expand Down Expand Up @@ -2472,7 +2473,9 @@ public sealed partial class ImageCodecInfo
public string? FormatDescription { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
public System.Guid FormatID { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
public string? MimeType { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
[System.CLSCompliantAttribute(false)]
public byte[][]? SignatureMasks { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
[System.CLSCompliantAttribute(false)]
public byte[][]? SignaturePatterns { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
public int Version { get { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } set { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); } }
public static System.Drawing.Imaging.ImageCodecInfo[] GetImageDecoders() { throw new System.PlatformNotSupportedException(System.SR.SystemDrawingCommon_PlatformNotSupported); }
Expand Down
1 change: 1 addition & 0 deletions src/System.Drawing.Common/src/System.Drawing.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<EnableAOTAnalyzer>false</EnableAOTAnalyzer>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<CLSCompliant>true</CLSCompliant>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<IsPackable>true</IsPackable>
<IsShipping>true</IsShipping>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public float Matrix44
/// <summary>
/// Initializes a new instance of the <see cref='ColorMatrix'/> class with the elements in the specified matrix.
/// </summary>
[CLSCompliant(false)]
public ColorMatrix(float[][] newColorMatrix)
{
_matrix00 = newColorMatrix[0][0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ internal ImageCodecInfo()

public int Version { get; set; }

[CLSCompliant(false)]
public byte[][]? SignaturePatterns { get; set; }

[CLSCompliant(false)]
public byte[][]? SignatureMasks { get; set; }

// Encoder/Decoder selection APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<AssemblyName>System.Windows.Forms.Design</AssemblyName>
<CLSCompliant>true</CLSCompliant>
<Deterministic>true</Deterministic>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace System.Drawing.Design;
/// Provides an editor that can perform default file searching for bitmap (.bmp)
/// files.
/// </summary>
[CLSCompliant(false)]
public class BitmapEditor : ImageEditor
{
protected static List<string> BitmapExtensions = ["bmp", "gif", "jpg", "jpeg", "png", "ico"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace System.Drawing.Design;
/// <summary>
/// Provides an editor for visually picking a color.
/// </summary>
[CLSCompliant(false)]
public partial class ColorEditor : UITypeEditor
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Drawing.Design;
/// <summary>
/// Provides an editor that can perform default file searching for cursor (.cur) files.
/// </summary>
[CLSCompliant(false)]
public partial class CursorEditor : UITypeEditor
{
private CursorUI? _cursorUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace System.Drawing.Design;
/// <summary>
/// Provides a font editor that is used to visually select and configure a Font object.
/// </summary>
[CLSCompliant(false)]
public class FontEditor : UITypeEditor
{
private FontDialog? _fontDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace System.Drawing.Design;
/// <summary>
/// Provides an editor for visually picking an image.
/// </summary>
[CLSCompliant(false)]
public class ImageEditor : UITypeEditor
{
private static readonly Type[] s_imageExtenders = [typeof(BitmapEditor), typeof(MetafileEditor)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace System.Drawing.Design;
/// <summary>
/// Extends Image's editor class to provide default file searching for metafile (.emf) files.
/// </summary>
[CLSCompliant(false)]
public class MetafileEditor : ImageEditor
{
protected override string GetFileDialogDescription() => SR.metafileFileDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Provides a design-time editor for specifying the <see cref="Control.Anchor"/> property.
/// </summary>
[CLSCompliant(false)]
public sealed partial class AnchorEditor : UITypeEditor
{
private AnchorUI? _anchorUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Provides an editor for setting the ToolStripStatusLabel BorderSides property..
/// </summary>
[CLSCompliant(false)]
public partial class BorderSidesEditor : UITypeEditor
{
private BorderSidesEditorUI? _borderSidesEditorUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ public virtual void AddComponent(IComponent component)
}
}

[CLSCompliant(false)]
protected virtual bool CanCreateComponentFromTool(ToolboxItem tool)
{
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
Expand Down Expand Up @@ -812,6 +813,7 @@ protected virtual bool CanDisplayComponent(IComponent component)
return TypeDescriptor.GetAttributes(component).Contains(DesignTimeVisibleAttribute.Yes);
}

[CLSCompliant(false)]
public void CreateComponentFromTool(ToolboxItem tool)
{
if (!CanCreateComponentFromTool(tool))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ protected override void Dispose(bool disposing)
/// Gets a value indicating whether the specified tool is supported by this
/// designer.
/// </summary>
[CLSCompliant(false)]
protected virtual bool GetToolSupported(ToolboxItem tool)
{
throw new NotImplementedException(SR.NotImplementedByDesign);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Implements the design time editor for specifying the <see cref="Control.Dock"/> property.
/// </summary>
[CLSCompliant(false)]
public sealed partial class DockEditor : UITypeEditor
{
private DockUI? _dockUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Provides an editor for filenames.
/// </summary>
[CLSCompliant(false)]
public class FileNameEditor : UITypeEditor
{
private OpenFileDialog? _openFileDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Provides an editor for choosing a folder from the filesystem.
/// </summary>
[CLSCompliant(false)]
public partial class FolderNameEditor : UITypeEditor
{
private FolderBrowser? _folderBrowser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Provides an editor that can perform default file searching for bitmap (.bmp) files.
/// </summary>
[CLSCompliant(false)]
public class ImageListImageEditor : ImageEditor
{
// Metafile types are not supported in the ImageListImageEditor and should not be displayed as an option.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ protected Size GridSize
/// This property is used by deriving classes to determine if the designer is
/// in a state where it has a valid MouseDragTool.
/// </summary>
[CLSCompliant(false)]
protected ToolboxItem MouseDragTool => _mouseDragTool;

/// <summary>
Expand Down Expand Up @@ -795,6 +796,7 @@ protected void CreateTool(ToolboxItem tool)
/// Creates the given tool in the currently selected control at the
/// given position. The default size for the tool is used.
/// </summary>
[CLSCompliant(false)]
protected void CreateTool(ToolboxItem tool, Point location)
{
CreateToolCore(tool, location.X, location.Y, 0, 0, true, false);
Expand All @@ -804,6 +806,7 @@ protected void CreateTool(ToolboxItem tool, Point location)
/// Creates the given tool in the currently selected control. The
/// tool is created with the provided shape.
/// </summary>
[CLSCompliant(false)]
protected void CreateTool(ToolboxItem tool, Rectangle bounds)
{
CreateToolCore(tool, bounds.X, bounds.Y, bounds.Width, bounds.Height, true, true);
Expand All @@ -813,6 +816,7 @@ protected void CreateTool(ToolboxItem tool, Rectangle bounds)
/// This is the worker method of all CreateTool methods. It is the only one
/// that can be overridden.
/// </summary>
[CLSCompliant(false)]
protected virtual IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
{
IComponent[] comp = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace System.Windows.Forms.Design;
/// <summary>
/// Provides an editor for picking shortcut keys.
/// </summary>
[CLSCompliant(false)]
public partial class ShortcutKeysEditor : UITypeEditor
{
private ShortcutKeysUI? _shortcutKeysUI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<AssemblyName>System.Windows.Forms.Primitives</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CLSCompliant>true</CLSCompliant>
<Nullable>enable</Nullable>
<!--
We align casing and naming with Win32 API. As such some types have all lower case names, which
Expand Down
1 change: 1 addition & 0 deletions src/System.Windows.Forms/src/System.Windows.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CLSCompliant>true</CLSCompliant>
<Nullable>enable</Nullable>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3626,6 +3626,7 @@ private static FONTDESC GetFONTDESCFromFont(Font font)
/// <summary>
/// Maps from an OLE COLOR to a System.Drawing.Color
/// </summary>
[CLSCompliant(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected static Color GetColorFromOleColor(uint color)
{
Expand All @@ -3635,6 +3636,7 @@ protected static Color GetColorFromOleColor(uint color)
/// <summary>
/// Maps from an System.Drawing.Color to an OLE COLOR
/// </summary>
[CLSCompliant(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected static uint GetOleColorFromColor(Color color)
{
Expand Down
Loading

0 comments on commit e30751e

Please sign in to comment.