Skip to content

Commit

Permalink
Merge branch 'release/8.0-staging' into merge/release/8.0-to-release/…
Browse files Browse the repository at this point in the history
…8.0-staging
  • Loading branch information
carlossanlop authored Nov 22, 2023
2 parents 2fc9614 + b56fb2a commit 708e33b
Show file tree
Hide file tree
Showing 39 changed files with 917 additions and 124 deletions.
8 changes: 8 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-emsdk -->
<add key="darc-pub-dotnet-emsdk-201f4da" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-201f4dae/nuget/v3/index.json" />
<add key="darc-pub-dotnet-emsdk-0af50f7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-0af50f73/nuget/v3/index.json" />
<add key="darc-pub-dotnet-emsdk-d75f77c" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-d75f77cb/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-emsdk -->
<!-- Begin: Package sources from dotnet-sdk -->
<!-- End: Package sources from dotnet-sdk -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
<!--
'src/test/PrepareTestAssets/PrepareTestAssets.proj' generates a NuGet.config file using this
Expand All @@ -28,5 +32,9 @@
</packageSources>
<disabledPackageSources>
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-sdk -->
<!-- End: Package sources from dotnet-sdk -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
</disabledPackageSources>
</configuration>
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@
<Sha>201f4dae9d1a1e105d8ba86d7ece61eed1f665e0</Sha>
<SourceBuild RepoName="emsdk" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="8.0.0-alpha.1.23556.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="8.0.0-alpha.1.23565.1">
<Uri>https:/dotnet/source-build-reference-packages</Uri>
<Sha>fa4c0e8f53ef2541a23e519af4dfb86cb88e1bae</Sha>
<Sha>95f83e27806330fec09edd96e06bba3acabe3f35</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="8.0.0-alpha.1.23518.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="8.0.0-alpha.1.23570.1">
<Uri>https:/dotnet/source-build-externals</Uri>
<Sha>3dc05150cf234f76f6936dcb2853d31a0da1f60e</Sha>
<Sha>e844aa02a05b90d8cbe499676ec6ee0f19ec4980</Sha>
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down Expand Up @@ -354,9 +354,9 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
<Sha>67613417f5e1af250e6ddfba79f8f2885d8e90fb</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="8.0.0-alpha.0.23563.1">
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="8.0.0-alpha.0.23570.2">
<Uri>https:/dotnet/hotreload-utils</Uri>
<Sha>12d02e5c2310be6460f896bc3aeb0ddf1e8926bc</Sha>
<Sha>5524f726f92ef862b415793758cebbd2a1950b70</Sha>
</Dependency>
<Dependency Name="System.Runtime.Numerics.TestData" Version="8.0.0-beta.23566.1">
<Uri>https:/dotnet/runtime-assets</Uri>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>8.0.0-prerelease.23407.2</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>8.0.0-prerelease.23407.2</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>8.0.0-prerelease.23407.2</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>8.0.0-alpha.0.23563.1</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>8.0.0-alpha.0.23570.2</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
<XUnitVersion>2.4.2</XUnitVersion>
<XUnitAnalyzersVersion>1.0.0</XUnitAnalyzersVersion>
<XUnitRunnerVisualStudioVersion>2.4.5</XUnitRunnerVisualStudioVersion>
Expand Down
28 changes: 28 additions & 0 deletions src/coreclr/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,34 @@ HRESULT ClrDataAccess::EnumMemCLRStatic(IN CLRDataEnumMemoryFlags flags)

ReportMem(g_gcDacGlobals.GetAddr(), sizeof(GcDacVars));

PTR_WSTR entryAssemblyPath = (PTR_WSTR)g_EntryAssemblyPath;
entryAssemblyPath.EnumMem();

// Triage dumps must not include full paths (PII data). Replace entry assembly path with file name only.
if (flags == CLRDATA_ENUM_MEM_TRIAGE)
{
WCHAR* path = entryAssemblyPath;
if (path != NULL)
{
size_t pathLen = u16_strlen(path) + 1;

// Get the file name based on the last directory separator
const WCHAR* name = u16_strrchr(path, DIRECTORY_SEPARATOR_CHAR_W);
if (name != NULL)
{
name += 1;
size_t len = u16_strlen(name) + 1;
wcscpy_s(path, len, name);

// Null out the rest of the buffer
for (size_t i = len; i < pathLen; ++i)
path[i] = W('\0');

DacUpdateMemoryRegion(entryAssemblyPath.GetAddr(), pathLen, (BYTE*)path);
}
}
}

// We need all of the dac variables referenced by the GC DAC global struct.
// This struct contains pointers to pointers, so we first dereference the pointers
// to obtain the location of the variable that's reported.
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/inc/daccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@
#include "crosscomp.h"
#endif

#include <dn-u16.h>

// Information stored in the DAC table of interest to the DAC implementation
// Note that this information is shared between all instantiations of ClrDataAccess, so initialize
// it just once in code:ClrDataAccess.GetDacGlobals (rather than use fields in ClrDataAccess);
Expand Down Expand Up @@ -1493,10 +1495,10 @@ class __Str16Ptr : public __DPtr<WCHAR>
}
void EnumMem(void) const
{
char* str = DacInstantiateStringW(m_addr, maxChars, false);
WCHAR* str = DacInstantiateStringW(m_addr, maxChars, false);
if (str)
{
DacEnumMemoryRegion(m_addr, strlen(str) + 1);
DacEnumMemoryRegion(m_addr, u16_strlen(str) + 1);
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,7 @@ DEFINE_DACVAR(SIZE_T, dac__g_clrNotificationArguments, ::g_clrNotificationArgume
DEFINE_DACVAR(bool, dac__g_metadataUpdatesApplied, ::g_metadataUpdatesApplied)
#endif

DEFINE_DACVAR(PTR_WSTR, dac__g_EntryAssemblyPath, ::g_EntryAssemblyPath)

#undef DEFINE_DACVAR
#undef DEFINE_DACVAR_NO_DUMP
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,11 @@ public void EmitDebugEHClauseInfo(ObjectNode node)
private static extern void EmitDebugFunctionInfo(IntPtr objWriter, byte[] methodName, int methodSize, uint methodTypeIndex);
public void EmitDebugFunctionInfo(ObjectNode node, int methodSize)
{
uint methodTypeIndex = 0;

var methodNode = node as IMethodNode;
if (methodNode != null)
if (node is IMethodNode methodNode)
{
methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method);
uint methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method);
EmitDebugFunctionInfo(_nativeObjectWriter, _currentNodeZeroTerminatedName.UnderlyingArray, methodSize, methodTypeIndex);
}

EmitDebugFunctionInfo(_nativeObjectWriter, _currentNodeZeroTerminatedName.UnderlyingArray, methodSize, methodTypeIndex);
}

[DllImport(NativeObjectWriterFileName)]
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/vm/corhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ HRESULT CorHost2::ExecuteAssembly(DWORD dwAppDomainId,

_ASSERTE (!pThread->PreemptiveGCDisabled());

if (g_EntryAssemblyPath == NULL)
{
// Store the entry assembly path for diagnostic purposes (for example, dumps)
size_t len = u16_strlen(pwzAssemblyPath) + 1;
NewArrayHolder<WCHAR> path { new WCHAR[len] };
wcscpy_s(path, len, pwzAssemblyPath);
g_EntryAssemblyPath = path.Extract();
}

Assembly *pAssembly = AssemblySpec::LoadAssembly(pwzAssemblyPath);

#if defined(FEATURE_MULTICOREJIT)
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ GVAL_IMPL_INIT(DWORD, g_debuggerWordTLSIndex, TLS_OUT_OF_INDEXES);
#endif
GVAL_IMPL_INIT(DWORD, g_TlsIndex, TLS_OUT_OF_INDEXES);

GVAL_IMPL_INIT(PTR_WSTR, g_EntryAssemblyPath, NULL);

#ifndef DACCESS_COMPILE

// <TODO> @TODO - PROMOTE. </TODO>
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/vm/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ GVAL_DECL(DWORD, g_debuggerWordTLSIndex);
#endif
GVAL_DECL(DWORD, g_TlsIndex);

// Full path to the managed entry assembly - stored for ease of identifying the entry asssembly for diagnostics
GVAL_DECL(PTR_WSTR, g_EntryAssemblyPath);

// Global System Information
extern SYSTEM_INFO g_SystemInfo;

Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/weakreferencenative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ FCIMPL1(FC_BOOL_RET, ComAwareWeakReferenceNative::HasInteropInfo, Object* pObjec
_ASSERTE(pObject != nullptr);

SyncBlock* pSyncBlock = pObject->PassiveGetSyncBlock();
_ASSERTE(pSyncBlock != nullptr);
return pSyncBlock->GetInteropInfoNoCreate() != nullptr;
return pSyncBlock != nullptr && pSyncBlock->GetInteropInfoNoCreate() != nullptr;
}
FCIMPLEND

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<Compile Include="Microsoft.Bcl.TimeProvider.Common.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesVersion)" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Bcl.AsyncInterfaces\ref\Microsoft.Bcl.AsyncInterfaces.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ System.TimeProvider
System.ITimer</PackageDescription>
<!-- This library uses IsPartialFacadeAssembly for which the compiler doesn't produce any XML documentation. -->
<UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ServicingVersion>1</ServicingVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -31,7 +33,7 @@ System.ITimer</PackageDescription>
</ItemGroup>

<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesVersion)" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Bcl.AsyncInterfaces\src\Microsoft.Bcl.AsyncInterfaces.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
Expand Down
91 changes: 78 additions & 13 deletions src/libraries/Microsoft.Extensions.Options/gen/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,83 @@ public void EmitCompareAttribute(string modifier, string prefix, string classNam
""");
}

public void EmitRangeAttribute(string modifier, string prefix, string className, string suffix)
public void EmitRangeAttribute(string modifier, string prefix, string className, string suffix, bool emitTimeSpanSupport)
{
OutGeneratedCodeAttribute();

string qualifiedClassName = $"{prefix}{suffix}_{className}";

string initializationString = emitTimeSpanSupport ?
"""
if (OperandType == typeof(global::System.TimeSpan))
{
if (!global::System.TimeSpan.TryParse((string)Minimum, culture, out global::System.TimeSpan timeSpanMinimum) ||
!global::System.TimeSpan.TryParse((string)Maximum, culture, out global::System.TimeSpan timeSpanMaximum))
{
throw new global::System.InvalidOperationException(c_minMaxError);
}
Minimum = timeSpanMinimum;
Maximum = timeSpanMaximum;
}
else
{
Minimum = ConvertValue(Minimum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
Maximum = ConvertValue(Maximum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
}
"""
:
"""
Minimum = ConvertValue(Minimum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
Maximum = ConvertValue(Maximum, culture) ?? throw new global::System.InvalidOperationException(c_minMaxError);
""";

string convertValue = emitTimeSpanSupport ?
"""
if (OperandType == typeof(global::System.TimeSpan))
{
if (value is global::System.TimeSpan)
{
convertedValue = value;
}
else if (value is string)
{
if (!global::System.TimeSpan.TryParse((string)value, formatProvider, out global::System.TimeSpan timeSpanValue))
{
return false;
}
convertedValue = timeSpanValue;
}
else
{
throw new global::System.InvalidOperationException($"A value type {value.GetType()} that is not a TimeSpan or a string has been given. This might indicate a problem with the source generator.");
}
}
else
{
try
{
convertedValue = ConvertValue(value, formatProvider);
}
catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
{
return false;
}
}
"""
:
"""
try
{
convertedValue = ConvertValue(value, formatProvider);
}
catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
{
return false;
}
""";



OutLn($$"""
[global::System.AttributeUsage(global::System.AttributeTargets.Property | global::System.AttributeTargets.Field | global::System.AttributeTargets.Parameter, AllowMultiple = false)]
{{modifier}} class {{qualifiedClassName}} : {{StaticValidationAttributeType}}
Expand Down Expand Up @@ -414,19 +485,20 @@ public override string FormatErrorMessage(string name) =>
string.Format(global::System.Globalization.CultureInfo.CurrentCulture, GetValidationErrorMessage(), name, Minimum, Maximum);
private bool NeedToConvertMinMax { get; }
private bool Initialized { get; set; }
private const string c_minMaxError = "The minimum and maximum values must be set to valid values.";

public override bool IsValid(object? value)
{
if (!Initialized)
{
if (Minimum is null || Maximum is null)
{
throw new global::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
throw new global::System.InvalidOperationException(c_minMaxError);
}
if (NeedToConvertMinMax)
{
System.Globalization.CultureInfo culture = ParseLimitsInInvariantCulture ? global::System.Globalization.CultureInfo.InvariantCulture : global::System.Globalization.CultureInfo.CurrentCulture;
Minimum = ConvertValue(Minimum, culture) ?? throw new global::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
Maximum = ConvertValue(Maximum, culture) ?? throw new global::System.InvalidOperationException("The minimum and maximum values must be set to valid values.");
{{initializationString}}
}
int cmp = ((global::System.IComparable)Minimum).CompareTo((global::System.IComparable)Maximum);
if (cmp > 0)
Expand All @@ -448,14 +520,7 @@ public override bool IsValid(object? value)
System.Globalization.CultureInfo formatProvider = ConvertValueInInvariantCulture ? global::System.Globalization.CultureInfo.InvariantCulture : global::System.Globalization.CultureInfo.CurrentCulture;
object? convertedValue;

try
{
convertedValue = ConvertValue(value, formatProvider);
}
catch (global::System.Exception e) when (e is global::System.FormatException or global::System.InvalidCastException or global::System.NotSupportedException)
{
return false;
}
{{convertValue}}

var min = (global::System.IComparable)Minimum;
var max = (global::System.IComparable)Maximum;
Expand Down Expand Up @@ -574,7 +639,7 @@ private void GenValidationAttributesClasses()
}
else if (attributeData.Key == _symbolHolder.RangeAttributeSymbol.Name)
{
EmitRangeAttribute(_optionsSourceGenContext.ClassModifier, Emitter.StaticAttributeClassNamePrefix, attributeData.Key, _optionsSourceGenContext.Suffix);
EmitRangeAttribute(_optionsSourceGenContext.ClassModifier, Emitter.StaticAttributeClassNamePrefix, attributeData.Key, _optionsSourceGenContext.Suffix, attributeData.Value is not null);
}
}

Expand Down
Loading

0 comments on commit 708e33b

Please sign in to comment.