Skip to content

Commit

Permalink
Wrap FileSystemEntry buffer in a struct to workaround visibility issu…
Browse files Browse the repository at this point in the history
…es with api compat (#73182)
  • Loading branch information
jkotas authored Aug 2, 2022
1 parent 3f7e4b9 commit 8d09271
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ CannotMakeMemberAbstract : Member 'public System.Boolean System.IO.FileSystemInf
CannotMakeMemberAbstract : Member 'public System.String System.IO.FileSystemInfo.Name' is abstract in the reference but is not abstract in the implementation.
CannotMakeMemberAbstract : Member 'public System.Boolean System.IO.FileSystemInfo.Exists.get()' is abstract in the reference but is not abstract in the implementation.
CannotMakeMemberAbstract : Member 'public System.String System.IO.FileSystemInfo.Name.get()' is abstract in the reference but is not abstract in the implementation.
# C# generates backing fields for fixed buffers as public.
TypesMustExist : Type 'System.IO.Enumeration.FileSystemEntry.<_fileNameBuffer>e__FixedBuffer' does not exist in the reference but it does exist in the implementation.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ namespace System.IO.Enumeration
/// Lower level view of FileSystemInfo used for processing and filtering find results.
/// </summary>
public unsafe ref partial struct FileSystemEntry
{
{
private Interop.Sys.DirectoryEntry _directoryEntry;
private bool _isDirectory;
private FileStatus _status;
private Span<char> _pathBuffer;
private ReadOnlySpan<char> _fullPath;
private ReadOnlySpan<char> _fileName;
private fixed char _fileNameBuffer[Interop.Sys.DirectoryEntry.NameBufferSize];
private FileNameBuffer _fileNameBuffer;

// Wrap the fixed buffer to workaround visibility issues in api compat verification
private struct FileNameBuffer
{
internal fixed char _buffer[Interop.Sys.DirectoryEntry.NameBufferSize];
}

internal static FileAttributes Initialize(
ref FileSystemEntry entry,
Expand Down Expand Up @@ -89,7 +95,7 @@ public ReadOnlySpan<char> FileName
{
if (_directoryEntry.NameLength != 0 && _fileName.Length == 0)
{
Span<char> buffer = MemoryMarshal.CreateSpan(ref _fileNameBuffer[0], Interop.Sys.DirectoryEntry.NameBufferSize);
Span<char> buffer = MemoryMarshal.CreateSpan(ref _fileNameBuffer._buffer[0], Interop.Sys.DirectoryEntry.NameBufferSize);
_fileName = _directoryEntry.GetName(buffer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ CannotMakeMemberAbstract : Member 'public System.Boolean System.IO.FileSystemInf
CannotMakeMemberAbstract : Member 'public System.String System.IO.FileSystemInfo.Name' is abstract in the reference but is not abstract in the implementation.
CannotMakeMemberAbstract : Member 'public System.Boolean System.IO.FileSystemInfo.Exists.get()' is abstract in the reference but is not abstract in the implementation.
CannotMakeMemberAbstract : Member 'public System.String System.IO.FileSystemInfo.Name.get()' is abstract in the reference but is not abstract in the implementation.
# C# generates backing fields for fixed buffers as public.
TypesMustExist : Type 'System.IO.Enumeration.FileSystemEntry.<_fileNameBuffer>e__FixedBuffer' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public void System.ModuleHandle..ctor(System.Reflection.Module)' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.String System.String System.Type.DefaultTypeNameWhenMissingMetadata' does not exist in the reference but it does exist in the implementation.
MembersMustExist : Member 'public System.String System.Type.FormatTypeNameForReflection()' does not exist in the reference but it does exist in the implementation.
Expand Down

0 comments on commit 8d09271

Please sign in to comment.