[net8.0-xcode15] Merge net8.0 into net8.0-xcode15.

This commit is contained in:
Rolf Bjarne Kvinge 2023-08-29 11:53:41 +02:00
Родитель 46214aee78 3fefa135f2
Коммит ef408d24a9
80 изменённых файлов: 519 добавлений и 306 удалений

Просмотреть файл

@ -721,6 +721,7 @@ DOTNET_MACOS_ASSEMBLY_NAME=Microsoft.macOS
DOTNET_PLATFORMS=
ifdef INCLUDE_IOS
ifdef ENABLE_DOTNET
DOTNET_PLATFORMS+=iOS
DOTNET_IOS_BITNESSES+=64
DOTNET_NATIVEAOT_PLATFORMS+=iOS
@ -742,9 +743,11 @@ DOTNET_IOS_RUNTIME_IDENTIFIERS_64+=iossimulator-x64 iossimulator-arm64
# All of them
DOTNET_IOS_RUNTIME_IDENTIFIERS=$(DOTNET_IOS_RUNTIME_IDENTIFIERS_32) $(DOTNET_IOS_RUNTIME_IDENTIFIERS_64)
endif # ENABLE_DOTNET
endif # INCLUDE_IOS
ifdef INCLUDE_TVOS
ifdef ENABLE_DOTNET
DOTNET_PLATFORMS+=tvOS
DOTNET_TVOS_BITNESSES+=64
DOTNET_NATIVEAOT_PLATFORMS+=tvOS
@ -754,6 +757,7 @@ else
DOTNET_TVOS_RUNTIME_IDENTIFIERS=tvossimulator-x64 tvossimulator-arm64
endif
DOTNET_TVOS_RUNTIME_IDENTIFIERS_64+=$(DOTNET_TVOS_RUNTIME_IDENTIFIERS)
endif # ENABLE_DOTNET
endif
ifdef INCLUDE_DOTNET_WATCHOS
@ -769,20 +773,24 @@ endif
endif
ifdef INCLUDE_MACCATALYST
ifdef ENABLE_DOTNET
DOTNET_PLATFORMS+=MacCatalyst
DOTNET_MACCATALYST_BITNESSES+=64
DOTNET_NATIVEAOT_PLATFORMS+=MacCatalyst
DOTNET_MACCATALYST_RUNTIME_IDENTIFIERS=maccatalyst-x64 maccatalyst-arm64
DOTNET_MACCATALYST_RUNTIME_IDENTIFIERS_64+=$(DOTNET_MACCATALYST_RUNTIME_IDENTIFIERS)
endif # ENABLE_DOTNET
endif
ifdef INCLUDE_MAC
ifdef ENABLE_DOTNET
DOTNET_PLATFORMS+=macOS
DOTNET_CORECLR_PLATFORMS+=macOS
DOTNET_MACOS_BITNESSES+=64
DOTNET_NATIVEAOT_PLATFORMS+=macOS
DOTNET_MACOS_RUNTIME_IDENTIFIERS=osx-x64 osx-arm64
DOTNET_MACOS_RUNTIME_IDENTIFIERS_64=$(DOTNET_MACOS_RUNTIME_IDENTIFIERS)
endif # ENABLE_DOTNET
endif
ifdef INCLUDE_IOS

Просмотреть файл

@ -180,7 +180,7 @@ git-clean-all:
@git submodule foreach -q --recursive 'git clean -xffdq && git reset --hard -q'
@for dir in $(DEPENDENCY_DIRECTORIES); do if test -d $(CURDIR)/$$dir; then echo "Cleaning $$dir" && cd $(CURDIR)/$$dir && git clean -xffdq && git reset --hard -q && git submodule foreach -q --recursive 'git clean -xffdq'; else echo "Skipped $$dir (does not exist)"; fi; done
@if [ -n "$(ENABLE_XAMARIN)" ] || [ -n "$(ENABLE_DOTNET)"]; then \
@if [ -n "$(ENABLE_XAMARIN)" ] || [ -n "$(ENABLE_DOTNET)" ]; then \
CONFIGURE_FLAGS=""; \
if [ -n "$(ENABLE_XAMARIN)" ]; then \
echo "Xamarin-specific build has been re-enabled"; \

Просмотреть файл

@ -20,6 +20,19 @@
<None Include="@(ObjcBindingCoreSource)" />
</ItemGroup>
<PropertyGroup Condition="'$(_PlatformName)' == 'MacCatalyst'">
<EnableDefaultMacCatalystReleaseEntitlements Condition="'$(EnableDefaultMacCatalystReleaseEntitlements)' == ''">True</EnableDefaultMacCatalystReleaseEntitlements>
<EnableDefaultMacCatalystDebugEntitlements Condition="'$(EnableDefaultMacCatalystDebugEntitlements)' == ''">True</EnableDefaultMacCatalystDebugEntitlements>
</PropertyGroup>
<ItemGroup Condition="'$(EnableDefaultMacCatalystDebugEntitlements)' == 'True' and '$(Configuration)' == 'Debug'">
<CustomEntitlements Include="com.apple.security.get-task-allow" Type="boolean" Value="true" />
</ItemGroup>
<ItemGroup Condition="'$(EnableDefaultMacCatalystReleaseEntitlements)' == 'True' and '$(Configuration)' == 'Release'">
<CustomEntitlements Include="com.apple.security.app-sandbox" Type="boolean" Value="true" />
</ItemGroup>
<!-- Architecture -->
<!-- If the old-style variables are set, use those -->
<PropertyGroup Condition=" '$(TargetArchitectures)' == '' ">

Просмотреть файл

@ -1285,77 +1285,12 @@
<TrimmerRootAssembly Include="@(_TrimmerRootAssemblyButOnlyIntermediateAssembly->'%(Filename)')" />
</ItemGroup>
<!--
Collect all the native linker args ILC would have used and use
them ourselves when we link natively.
Unfortunately there's a major difference between LinkerArgs (as
used by ILC) and our _CustomLinkerFlags: ILC splits on space in
LinkerArg, while we quote (when necessary) the items in
_CustomLinkerFlags.
Example:
<LinkerArg Include="-framework UIKit" />
ILC will pass that as two separate arguments to the native
compiler
<_CustomLinkFlags Include="-framework UIKit" />
We'll pass that as a single argument ('-framework UIKit')
to the native compiler (which the native compiler doesn't
like)
So we need to convert the list of space-separated items in
LinkerArg to space-preserved items in _CustomLinkFlags.
How to do this in MSBuild is somewhat non-obvious: first we
convert the LinkerArg item group to a property where every item is
separated by a semi-colon, and where we've also replaced spaces by
semi-colons. This means we have a property where every flag we
want is separated by a semi-colon. Then we split on the property
string on a semi-colon and add those items to the _CustomLinkFlags
item group.
Note: this means ILC doesn't support linker flags with spaces in them.
Additionally, the LinkerArg item group are actually passed to the
native compiler by the NativeAOT build tasks, not the native
linker. This means they might contain wrapped linker arguments:
'-Wl,...', which the compiler understands, but not the linker.
Thus we need to unwrap the (compiler) arguments in LinkerArgs to
be actual linker arguments. Also note that there can be multiple
linker arguments passed using a single compiler argument, and
those are separated by a comma: "-Wl,-linkerarg1,-linkerarg2", so
we need to split those into multiple linker arguments as well. And
to make things even more complicated, there may be quotes as well:
<LinkerArg>'-Wl,-linkerarg1,-linkerarg2'</LinkerArg>.
-->
<PropertyGroup>
<_LinkerArgsSplitBySemiColon>@(LinkerArg->Replace(' ',';'))</_LinkerArgsSplitBySemiColon>
</PropertyGroup>
<ItemGroup>
<_AllLinkerArgs Include="$(_LinkerArgsSplitBySemiColon.Split(';'))" />
<_LinkerArgsWhichAreReallyCompilerArgs Include="@(_AllLinkerArgs)" Condition="$([System.String]::new('%(Identity)').StartsWith('-Wl,'))">
<TransformedArgument>$([System.String]::new('%(Identity)').Substring(4))</TransformedArgument>
</_LinkerArgsWhichAreReallyCompilerArgs>
<!-- Handle quoted arguments: <LinkerArg>'-Wl,-linkerarg'</LinkerArg> -->
<_LinkerArgsWhichAreReallyCompilerArgs Include="@(_AllLinkerArgs)" Condition="$([System.String]::new('%(Identity)').StartsWith('%27-Wl,')) And $([System.String]::new('%(Identity)').EndsWith('%27'))">
<TransformedArgument>$([System.String]::new('%(Identity)').Substring(5, $([MSBuild]::Subtract($([System.String]::new('%(Identity)').Length), 6))))</TransformedArgument>
</_LinkerArgsWhichAreReallyCompilerArgs>
<_CompilerArgsTransformedToLinkerArgs Include="@(_LinkerArgsWhichAreReallyCompilerArgs->'%(TransformedArgument)')" />
</ItemGroup>
<PropertyGroup>
<_CompilerArgsTransformedToLinkerArgsSplitByComma>@(_CompilerArgsTransformedToLinkerArgs->Replace(',',';'))</_CompilerArgsTransformedToLinkerArgsSplitByComma>
</PropertyGroup>
<ItemGroup>
<_AllLinkerArgs Remove="@(_LinkerArgsWhichAreReallyCompilerArgs)" />
<_AllLinkerArgs Include="$(_CompilerArgsTransformedToLinkerArgsSplitByComma.Split(';'))" />
<_CustomLinkFlags Include="@(_AllLinkerArgs)" />
<!-- Collect extra native linker flags ILC would have used -->
<_CustomLinkFlags Include="@(NativeLibrary)" />
<_CustomLinkFlags Include="@(NativeSystemLibrary->'-l%(Identity)')" />
<_CustomLinkFlags Include="@(NativeFramework->'-Wl,-framework,%(Identity)')" />
<_CustomLinkFlags Include="@(ExtraLinkerArg->'-Wl,%(Identity)')" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -1,30 +1,30 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-rc.2.23422.3">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="8.0.100-rc.2.23427.4">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>287aaf0581126c529df97b7155c9fe70f0f8acce</Sha>
<Sha>c5e45fd659da4a8adfee8176ad7b6e4b3ac62ab8</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="8.0.0-rc.2.23418.14" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="8.0.0-rc.2.23426.4" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>90b92bb265a412592c4c152983d7b30c92236dbe</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<!-- Set TRACKING_DOTNET_RUNTIME_SEPARATELY to something in Make.config if removing the CoherentParentDependency on Microsoft.Dotnet.Sdk.Internal -->
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23418.14" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23426.4" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>90b92bb265a412592c4c152983d7b30c92236dbe</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<!-- This is required for our test apps to build; in some cases Microsoft.AspNetCore.App is pulled in, and when building test apps the build needs to be able to resolve that -->
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="8.0.0-rc.2.23421.27" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="8.0.0-rc.2.23425.11" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>fe448a7958355091ea97ca19e7c93f517c4df8fa</Sha>
<Sha>fcc98f5c65ed50bfc024dbb0df1a2fa61a0790a3</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport" Version="8.0.0-rc.1.23415.5" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>66dbaefff04250dc72849f0172e0c53bcfb3ab38</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.23407.2" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.23421.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/cecil</Uri>
<Sha>2f4ef297939628143389ddeea569874ded0b1c1b</Sha>
<Sha>d412306c1514a26737574838900052d8758da5be</Sha>
</Dependency>
<!-- This is a subscription of the .NET 7 versions of our packages -->
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="16.4.7098">
@ -57,9 +57,9 @@
<Uri>https://github.com/dotnet/templating</Uri>
<Sha />
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="8.0.0-prerelease.23407.2">
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="8.0.0-prerelease.23416.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>480b9159eb7e69b182a87581d5a336e97e0b6dae</Sha>
<Sha>5a4c0c4662e26da63aa22d0bd239ea8576c1cda7</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>

Просмотреть файл

@ -2,14 +2,14 @@
<!--Package versions-->
<PropertyGroup>
<!-- Versions updated by maestro -->
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-rc.2.23422.3</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>8.0.0-rc.2.23418.14</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>8.0.100-rc.2.23427.4</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>8.0.0-rc.2.23426.4</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>6.0.0-beta.21212.6</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>8.0.0-rc.2.23418.14</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-rc.1.23415.5</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
<MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>7.0.7</MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.100-alpha.1.21601.1</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.23407.2</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.23421.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>8.0.0-prerelease.23407.2</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
<!-- Manually updated versions -->
<Emscriptennet7WorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion)</Emscriptennet7WorkloadVersion>

2
external/api-tools поставляемый

@ -1 +1 @@
Subproject commit 254f0e043047abb9744b25df7cd9d238f899e5a6
Subproject commit c7d5208967d6d46fdebcac82ade488f00e1fcc50

Просмотреть файл

@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.100-rc.2.23422.3"
"version": "8.0.100-rc.2.23427.4"
}
}

Просмотреть файл

@ -7,7 +7,7 @@ MONO_BRANCH := $(shell cd $(MONO_PATH) 2> /dev/null && git symbolic-ref --sho
endif
ifdef ENABLE_XAMARIN
NEEDED_MACCORE_VERSION := fd15821e6780a7439df467c69eb511a046adfa06
NEEDED_MACCORE_VERSION := 48e39158bd4730d5426fcb3ab570903161580e15
NEEDED_MACCORE_BRANCH := main
MACCORE_DIRECTORY := maccore

Просмотреть файл

@ -184,13 +184,8 @@ namespace Xamarin.MacDev.Tasks {
Directory.CreateDirectory (OutputDirectory);
var aotAssemblyFiles = new List<ITaskItem> ();
var processes = new Task<Execution> [assembliesToAOT.Count];
var environment = new Dictionary<string, string?> {
{ "MONO_PATH", Path.GetFullPath (InputDirectory) },
};
var globalAotArguments = AotArguments?.Select (v => v.ItemSpec).ToList ();
var listOfArguments = new List<(IList<string> Arguments, string Input)> ();
for (var i = 0; i < assembliesToAOT.Count; i++) {
var asm = assembliesToAOT [i];
var input = asm.GetMetadata ("Input");
@ -215,6 +210,7 @@ namespace Xamarin.MacDev.Tasks {
Log.LogError (MSBStrings.E7071, /* Unable to parse the AOT compiler arguments: {0} ({1}) */ processArguments, ex2!.Message);
return false;
}
arguments.Add ($"--path={Path.GetFullPath (InputDirectory)}");
arguments.Add ($"{string.Join (",", parsedArguments)}");
if (globalAotArguments?.Any () == true)
arguments.Add ($"--aot={string.Join (",", globalAotArguments)}");
@ -224,16 +220,20 @@ namespace Xamarin.MacDev.Tasks {
else
arguments.Add (input);
processes [i] = ExecuteAsync (AOTCompilerPath, arguments, environment: environment, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
.ContinueWith ((v) => {
if (v.Result.ExitCode != 0)
Log.LogError (MSBStrings.E7118 /* Failed to AOT compile {0}, the AOT compiler exited with code {1} */, Path.GetFileName (input), v.Result.ExitCode);
return System.Threading.Tasks.Task.FromResult<Execution> (v.Result);
}).Unwrap ();
listOfArguments.Add (new (arguments, input));
}
System.Threading.Tasks.Task.WaitAll (processes);
Parallel.ForEach (listOfArguments, (arg) => {
ExecuteAsync (AOTCompilerPath, arg.Arguments, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
.ContinueWith ((v) => {
if (v.Result.ExitCode != 0)
Log.LogError (MSBStrings.E7118 /* Failed to AOT compile {0}, the AOT compiler exited with code {1} */, Path.GetFileName (arg.Input), v.Result.ExitCode);
return System.Threading.Tasks.Task.FromResult<Execution> (v.Result);
})
.Unwrap ()
.Wait ();
});
AssemblyFiles = aotAssemblyFiles.ToArray ();

Просмотреть файл

@ -74,7 +74,7 @@ namespace AudioToolbox {
fixed (AudioClassDescription* item = &descriptions[0]) {
uint successfulCodecs;
int size = sizeof (uint);
var ptr_size = Marshal.SizeOf (typeof (AudioClassDescription)) * descriptions.Length;
var ptr_size = Marshal.SizeOf<AudioClassDescription> () * descriptions.Length;
var res = AudioFormatPropertyNative.AudioFormatGetProperty (AudioFormatProperty.HardwareCodecCapabilities, ptr_size, item, ref size, out successfulCodecs);
if (res != 0)
return null;

Просмотреть файл

@ -602,7 +602,7 @@ namespace AudioToolbox {
// write at some unknown pointer location, similar situation happens when initialization
// size does not match data size
//
int size = Marshal.SizeOf (data [0]);
int size = Marshal.SizeOf<AudioStreamPacketDescription> ();
// Clear our buffer if it's not big enough
if (inst.packetDescriptionSize < data.Length && inst.packetDescriptions != IntPtr.Zero) {
Marshal.FreeHGlobal (inst.packetDescriptions);

Просмотреть файл

@ -217,7 +217,7 @@ namespace AudioToolbox {
using (var cfs = new CFString (extension)) {
uint value;
uint size = sizeof (AudioFileType);
if (AudioFileGetGlobalInfo (AudioFileGlobalProperty.TypesForExtension, (uint) Marshal.SizeOf (typeof (IntPtr)), cfs.Handle, ref size, out value) != 0)
if (AudioFileGetGlobalInfo (AudioFileGlobalProperty.TypesForExtension, (uint) IntPtr.Size, cfs.Handle, ref size, out value) != 0)
return null;
return (AudioFileType) value;

Просмотреть файл

@ -427,7 +427,7 @@ namespace AudioToolbox {
try {
LastError = AudioFileStreamGetProperty (handle, property, ref size, buffer);
if (LastError == 0) {
return (T) Marshal.PtrToStructure (buffer, typeof (T))!;
return Marshal.PtrToStructure<T> (buffer)!;
}
return null;

Просмотреть файл

@ -74,7 +74,7 @@ namespace AudioToolbox {
if (size == 0)
return Array.Empty<T> ();
var data = new T [size / Marshal.SizeOf (typeof (T))];
var data = new T [size / Marshal.SizeOf<T> ()];
fixed (T* ptr = data) {
var res = AudioFormatPropertyNative.AudioFormatGetProperty (prop, sizeof (AudioFormatType), ref format, ref size, (IntPtr) ptr);
if (res != 0)

Просмотреть файл

@ -950,7 +950,7 @@ namespace AudioToolbox {
try {
r = AudioQueueGetProperty (handle, (uint) property, buffer, ref size);
if (r == 0) {
T result = (T) Marshal.PtrToStructure (buffer, typeof (T))!;
T result = Marshal.PtrToStructure<T> (buffer)!;
return result;
}
@ -974,7 +974,7 @@ namespace AudioToolbox {
try {
r = AudioQueueGetProperty (handle, (uint) property, buffer, ref size);
if (r == 0) {
T result = (T) Marshal.PtrToStructure (buffer, typeof (T))!;
T result = Marshal.PtrToStructure<T> (buffer)!;
return result;
}

Просмотреть файл

@ -215,7 +215,7 @@ namespace AudioUnit {
public ResourceUsageInfo? ResourceUsage {
get {
return GetStrongDictionary<ResourceUsageInfo> (resourceUsageK);
return GetStrongDictionary<ResourceUsageInfo> (resourceUsageK, (dict) => new ResourceUsageInfo (dict));
}
set {
SetNativeValue (resourceUsageK, value?.Dictionary, true);

Просмотреть файл

@ -401,7 +401,7 @@ namespace AudioUnit {
scope,
audioUnitElement,
ref audioFormat,
(uint) Marshal.SizeOf (audioFormat));
(uint) Marshal.SizeOf<AudioToolbox.AudioStreamBasicDescription> ());
if (err != 0)
throw new AudioUnitException (err);
}
@ -414,13 +414,13 @@ namespace AudioUnit {
scope,
audioUnitElement,
ref audioFormat,
(uint) Marshal.SizeOf (audioFormat));
(uint) Marshal.SizeOf<AudioToolbox.AudioStreamBasicDescription> ());
}
public uint GetCurrentDevice (AudioUnitScopeType scope, uint audioUnitElement = 0)
{
uint device = 0;
int size = Marshal.SizeOf (typeof (uint));
int size = sizeof (uint);
var err = AudioUnitGetProperty (Handle,
AudioUnitPropertyIDType.CurrentDevice,
scope,
@ -453,7 +453,7 @@ namespace AudioUnit {
// https://developer.apple.com/library/mac/technotes/tn2223/_index.html
uint inputDevice;
uint size = (uint) Marshal.SizeOf (typeof (uint));
uint size = (uint) sizeof (uint);
var theAddress = new AudioObjectPropertyAddress (
AudioObjectPropertySelector.DefaultInputDevice,
AudioObjectPropertyScope.Global,
@ -478,13 +478,13 @@ namespace AudioUnit {
scope,
audioUnitElement,
ref inputDevice,
(uint) Marshal.SizeOf (inputDevice));
(uint) sizeof (uint));
}
public AudioStreamBasicDescription GetAudioFormat (AudioUnitScopeType scope, uint audioUnitElement = 0)
{
var audioFormat = new AudioStreamBasicDescription ();
uint size = (uint) Marshal.SizeOf (audioFormat);
uint size = (uint) Marshal.SizeOf<AudioStreamBasicDescription> ();
var err = AudioUnitGetProperty (Handle,
AudioUnitPropertyIDType.StreamFormat,
@ -501,7 +501,7 @@ namespace AudioUnit {
public ClassInfoDictionary? GetClassInfo (AudioUnitScopeType scope = AudioUnitScopeType.Global, uint audioUnitElement = 0)
{
IntPtr ptr = new IntPtr ();
int size = Marshal.SizeOf (typeof (IntPtr));
int size = IntPtr.Size;
var res = AudioUnitGetProperty (Handle, AudioUnitPropertyIDType.ClassInfo, scope, audioUnitElement,
ref ptr, ref size);
@ -515,7 +515,7 @@ namespace AudioUnit {
{
var ptr = preset.Dictionary.Handle;
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.ClassInfo, scope, audioUnitElement,
ref ptr, Marshal.SizeOf (typeof (IntPtr)));
ref ptr, IntPtr.Size);
}
public unsafe AudioUnitParameterInfo []? GetParameterList (AudioUnitScopeType scope = AudioUnitScopeType.Global, uint audioUnitElement = 0)
@ -553,7 +553,7 @@ namespace AudioUnit {
var data = instrumentData.ToStruct ();
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.LoadInstrument, scope, audioUnitElement,
ref data, Marshal.SizeOf (typeof (AUSamplerInstrumentData)));
ref data, Marshal.SizeOf<AUSamplerInstrumentData> ());
}
public AudioUnitStatus MakeConnection (AudioUnit sourceAudioUnit, uint sourceOutputNumber, uint destInputNumber)
@ -564,7 +564,7 @@ namespace AudioUnit {
DestInputNumber = destInputNumber
};
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.MakeConnection, AudioUnitScopeType.Input, 0, ref auc, Marshal.SizeOf (typeof (AudioUnitConnection)));
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.MakeConnection, AudioUnitScopeType.Input, 0, ref auc, Marshal.SizeOf<AudioUnitConnection> ());
}
public AudioUnitStatus SetEnableIO (bool enableIO, AudioUnitScopeType scope, uint audioUnitElement = 0)
@ -667,7 +667,7 @@ namespace AudioUnit {
cb.Proc = CreateRenderCallback;
#endif
cb.ProcRefCon = GCHandle.ToIntPtr (gcHandle);
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.SetRenderCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf (cb));
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.SetRenderCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf<AURenderCallbackStruct> ());
}
#if NET
@ -721,7 +721,7 @@ namespace AudioUnit {
cb.Proc = CreateInputCallback;
#endif
cb.ProcRefCon = GCHandle.ToIntPtr (gcHandle);
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.SetInputCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf (cb));
return AudioUnitSetProperty (Handle, AudioUnitPropertyIDType.SetInputCallback, scope, audioUnitElement, ref cb, Marshal.SizeOf<AURenderCallbackStruct> ());
}
#if NET
[UnmanagedCallersOnly]
@ -1065,7 +1065,7 @@ namespace AudioUnit {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (region));
var safr = region.GetAudioFileRegion ();
return AudioUnitSetProperty (GetCheckedHandle (), AudioUnitPropertyIDType.ScheduledFileRegion, AudioUnitScopeType.Global, 0, ref safr, Marshal.SizeOf (safr));
return AudioUnitSetProperty (GetCheckedHandle (), AudioUnitPropertyIDType.ScheduledFileRegion, AudioUnitScopeType.Global, 0, ref safr, Marshal.SizeOf<AUScheduledAudioFileRegion.ScheduledAudioFileRegion> ());
}
[DllImport (Constants.AudioUnitLibrary)]
@ -1074,7 +1074,7 @@ namespace AudioUnit {
public AudioUnitStatus SetScheduleStartTimeStamp (AudioTimeStamp timeStamp)
{
return AudioUnitSetProperty (GetCheckedHandle (), AudioUnitPropertyIDType.ScheduleStartTimeStamp, AudioUnitScopeType.Global, 0, ref timeStamp, Marshal.SizeOf (timeStamp));
return AudioUnitSetProperty (GetCheckedHandle (), AudioUnitPropertyIDType.ScheduleStartTimeStamp, AudioUnitScopeType.Global, 0, ref timeStamp, Marshal.SizeOf<AudioTimeStamp> ());
}
public AudioUnitStatus SetScheduledFiles (AudioFile audioFile)
@ -1083,7 +1083,7 @@ namespace AudioUnit {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (audioFile));
var audioFilehandle = audioFile.Handle;
return AudioUnitSetProperty (GetCheckedHandle (), AudioUnitPropertyIDType.ScheduledFileIDs, AudioUnitScopeType.Global, 0, ref audioFilehandle, Marshal.SizeOf (Handle));
return AudioUnitSetProperty (GetCheckedHandle (), AudioUnitPropertyIDType.ScheduledFileIDs, AudioUnitScopeType.Global, 0, ref audioFilehandle, Marshal.SizeOf<NativeHandle> ());
}
[DllImport (Constants.AudioUnitLibrary)]
@ -1255,7 +1255,7 @@ namespace AudioUnit {
public AURenderEvent? Next {
get {
if (UnsafeNext is not null)
return (AURenderEvent?) Marshal.PtrToStructure ((IntPtr) UnsafeNext, typeof (AURenderEvent));
return Marshal.PtrToStructure<AURenderEvent> ((IntPtr) UnsafeNext);
return null;
}
}
@ -1295,7 +1295,7 @@ namespace AudioUnit {
public AURenderEvent? Next {
get {
if (UnsafeNext is not null)
return (AURenderEvent?) Marshal.PtrToStructure ((IntPtr) UnsafeNext, typeof (AURenderEvent));
return Marshal.PtrToStructure<AURenderEvent> ((IntPtr) UnsafeNext);
return null;
}
}
@ -1322,7 +1322,7 @@ namespace AudioUnit {
// public AURenderEvent? Next {
// get {
// if (UnsafeNext is not null)
// return (AURenderEvent?) Marshal.PtrToStructure ((IntPtr)UnsafeNext, typeof (AURenderEvent));
// return Marshal.PtrToStructure<AURenderEvent> ((IntPtr)UnsafeNext);
// return null;
// }
// }

Просмотреть файл

@ -104,7 +104,7 @@ namespace AudioUnit {
public IntPtr? AudioFile {
get {
uint size = (uint) Marshal.SizeOf (typeof (IntPtr));
uint size = (uint) IntPtr.Size;
IntPtr value;
if (ExtAudioFileGetProperty (_extAudioFile, PropertyIDType.AudioFile, ref size, out value) != ExtAudioFileError.OK)
return null;
@ -142,7 +142,7 @@ namespace AudioUnit {
public AudioStreamBasicDescription FileDataFormat {
get {
AudioStreamBasicDescription dc = new AudioStreamBasicDescription ();
uint size = (uint) Marshal.SizeOf (typeof (AudioStreamBasicDescription));
uint size = (uint) Marshal.SizeOf<AudioStreamBasicDescription> ();
int err = ExtAudioFileGetProperty (_extAudioFile, PropertyIDType.FileDataFormat, ref size, ref dc);
if (err != 0) {
throw new InvalidOperationException (String.Format ("Error code:{0}", err));
@ -154,7 +154,7 @@ namespace AudioUnit {
public AudioStreamBasicDescription ClientDataFormat {
get {
uint size = (uint) Marshal.SizeOf (typeof (AudioStreamBasicDescription));
uint size = (uint) Marshal.SizeOf<AudioStreamBasicDescription> ();
AudioStreamBasicDescription value = new AudioStreamBasicDescription ();
if (ExtAudioFileGetProperty (_extAudioFile, PropertyIDType.ClientDataFormat, ref size, ref value) != (int) ExtAudioFileError.OK)
return default (AudioStreamBasicDescription);
@ -164,7 +164,7 @@ namespace AudioUnit {
set {
int err = ExtAudioFileSetProperty (_extAudioFile, PropertyIDType.ClientDataFormat,
(uint) Marshal.SizeOf (value), ref value);
(uint) Marshal.SizeOf<AudioStreamBasicDescription> (), ref value);
if (err != 0) {
throw new InvalidOperationException (String.Format ("Error code:{0}", err));
}
@ -343,7 +343,7 @@ namespace AudioUnit {
{
IntPtr value = IntPtr.Zero;
return ExtAudioFileSetProperty (_extAudioFile, PropertyIDType.ConverterConfig,
Marshal.SizeOf (value), value);
IntPtr.Size, value);
}
public void Dispose ()

Просмотреть файл

@ -678,7 +678,7 @@ namespace CoreFoundation {
// CFNetworkExecuteProxyAutoConfigurationScript or CFNetworkExecuteProxyAutoConfigurationURL call
// that triggered this callback.
// Well, that is NOT TRUE, the client passed is the client.Info pointer not the client.
var pacCbData = (PACProxyCallbackData) Marshal.PtrToStructure (client, typeof (PACProxyCallbackData))!;
var pacCbData = Marshal.PtrToStructure<PACProxyCallbackData> (client)!;
// make sure is not released, will be released by the parsing method.
if (proxyList != IntPtr.Zero) {
CFObject.CFRetain (proxyList);
@ -690,7 +690,7 @@ namespace CoreFoundation {
}
// stop the CFRunLoop
var runLoop = new CFRunLoop (pacCbData.CFRunLoopPtr, false);
Marshal.StructureToPtr (pacCbData, client, false);
Marshal.StructureToPtr<PACProxyCallbackData> (pacCbData, client, false);
runLoop.Stop ();
}
@ -708,9 +708,9 @@ namespace CoreFoundation {
// build a struct that will have all the needed info for the callback
var pacCbData = new PACProxyCallbackData ();
pacCbData.CFRunLoopPtr = runLoop.Handle;
var pacDataPtr = Marshal.AllocHGlobal (Marshal.SizeOf (pacCbData));
var pacDataPtr = Marshal.AllocHGlobal (Marshal.SizeOf<PACProxyCallbackData> ());
try {
Marshal.StructureToPtr (pacCbData, pacDataPtr, false);
Marshal.StructureToPtr<PACProxyCallbackData> (pacCbData, pacDataPtr, false);
var clientContext = new CFStreamClientContext ();
clientContext.Info = pacDataPtr;
@ -745,7 +745,7 @@ namespace CoreFoundation {
if (cancellationToken.IsCancellationRequested)
throw new OperationCanceledException ("Operation was cancelled.");
pacCbData = (PACProxyCallbackData) Marshal.PtrToStructure (pacDataPtr, typeof (PACProxyCallbackData))!;
pacCbData = Marshal.PtrToStructure<PACProxyCallbackData> (pacDataPtr)!;
// get data from the struct
proxies = pacCbData.ProxyList;
outError = pacCbData.Error;
@ -772,9 +772,9 @@ namespace CoreFoundation {
// build a struct that will have all the needed info for the callback
var pacCbData = new PACProxyCallbackData ();
pacCbData.CFRunLoopPtr = runLoop.Handle;
var pacDataPtr = Marshal.AllocHGlobal (Marshal.SizeOf (pacCbData));
var pacDataPtr = Marshal.AllocHGlobal (Marshal.SizeOf<PACProxyCallbackData> ());
try {
Marshal.StructureToPtr (pacCbData, pacDataPtr, false);
Marshal.StructureToPtr<PACProxyCallbackData> (pacCbData, pacDataPtr, false);
var clientContext = new CFStreamClientContext ();
clientContext.Info = pacDataPtr;
@ -790,7 +790,7 @@ namespace CoreFoundation {
runLoop.RunInMode (mode, double.MaxValue, false);
runLoop.RemoveSource (loopSource, mode);
}
pacCbData = (PACProxyCallbackData) Marshal.PtrToStructure (pacDataPtr, typeof (PACProxyCallbackData))!;
pacCbData = Marshal.PtrToStructure<PACProxyCallbackData> (pacDataPtr)!;
// get data from the struct
outError = pacCbData.Error;
#if NET

Просмотреть файл

@ -708,9 +708,9 @@ namespace CoreFoundation {
CFStreamEventType.CanAcceptBytes | CFStreamEventType.ErrorOccurred |
CFStreamEventType.EndEncountered;
var ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (CFStreamClientContext)));
var ptr = Marshal.AllocHGlobal (Marshal.SizeOf<CFStreamClientContext> ());
try {
Marshal.StructureToPtr (ctx, ptr, false);
Marshal.StructureToPtr<CFStreamClientContext> (ctx, ptr, false);
bool clientSet;
#if NET8_0_OR_GREATER
unsafe {

Просмотреть файл

@ -498,7 +498,7 @@ namespace CoreGraphics {
return;
IntPtr ptr = Marshal.ReadIntPtr (element_ptr, IntPtr.Size);
int ptsize = Marshal.SizeOf (typeof (CGPoint));
int ptsize = Marshal.SizeOf<CGPoint> ();
switch (element.Type) {
case CGPathElementType.CloseSubpath:

Просмотреть файл

@ -86,19 +86,19 @@ namespace CoreMedia {
{
var lib = Libraries.CoreMedia.Handle;
var retZero = Dlfcn.dlsym (lib, "kCMTimeRangeZero");
Zero = (CMTimeRange) Marshal.PtrToStructure (retZero, typeof (CMTimeRange))!;
Zero = Marshal.PtrToStructure<CMTimeRange> (retZero)!;
var retInvalid = Dlfcn.dlsym (lib, "kCMTimeRangeInvalid");
#if !XAMCORE_3_0
#pragma warning disable CS0618 // Type or member is obsolete
Invalid = (CMTimeRange) Marshal.PtrToStructure (retInvalid, typeof (CMTimeRange))!;
Invalid = Marshal.PtrToStructure<CMTimeRange> (retInvalid)!;
#pragma warning restore CS0618 // Type or member is obsolete
#endif
InvalidRange = (CMTimeRange) Marshal.PtrToStructure (retInvalid, typeof (CMTimeRange))!;
InvalidRange = Marshal.PtrToStructure<CMTimeRange> (retInvalid)!;
var retMappingInvalid = Dlfcn.dlsym (lib, "kCMTimeMappingInvalid");
if (retMappingInvalid != IntPtr.Zero)
InvalidMapping = (CMTimeRange) Marshal.PtrToStructure (retMappingInvalid, typeof (CMTimeRange))!;
InvalidMapping = Marshal.PtrToStructure<CMTimeRange> (retMappingInvalid)!;
TimeMappingSourceKey = Dlfcn.GetStringConstant (lib, "kCMTimeMappingSourceKey");
TimeMappingTargetKey = Dlfcn.GetStringConstant (lib, "kCMTimeMappingTargetKey");

Просмотреть файл

@ -667,7 +667,7 @@ namespace CoreMidi {
case MidiNotificationMessageId.ObjectAdded:
var eoa = client?.ObjectAdded;
if (eoa is not null) {
var data = (MidiObjectAddRemoveNotification) Marshal.PtrToStructure (message, typeof (MidiObjectAddRemoveNotification))!;
var data = Marshal.PtrToStructure<MidiObjectAddRemoveNotification> (message)!;
eoa (client, new ObjectAddedOrRemovedEventArgs (MidiObjectFromType (data.ParentType, data.Parent),
MidiObjectFromType (data.ChildType, data.Child)));
}
@ -675,7 +675,7 @@ namespace CoreMidi {
case MidiNotificationMessageId.ObjectRemoved:
var eor = client?.ObjectRemoved;
if (eor is not null) {
var data = (MidiObjectAddRemoveNotification) Marshal.PtrToStructure (message, typeof (MidiObjectAddRemoveNotification))!;
var data = Marshal.PtrToStructure<MidiObjectAddRemoveNotification> (message)!;
eor (client, new ObjectAddedOrRemovedEventArgs (MidiObjectFromType (data.ParentType, data.Parent),
MidiObjectFromType (data.ChildType, data.Child)));
}
@ -683,7 +683,7 @@ namespace CoreMidi {
case MidiNotificationMessageId.PropertyChanged:
var epc = client?.PropertyChanged;
if (epc is not null) {
var data = (MidiObjectPropertyChangeNotification) Marshal.PtrToStructure (message, typeof (MidiObjectPropertyChangeNotification))!;
var data = Marshal.PtrToStructure<MidiObjectPropertyChangeNotification> (message)!;
epc (client, new ObjectPropertyChangedEventArgs (
MidiObjectFromType (data.ObjectType, data.ObjectHandle), CFString.FromHandle (data.PropertyName)));
}
@ -701,7 +701,7 @@ namespace CoreMidi {
case MidiNotificationMessageId.IOError:
var eio = client?.IOError;
if (eio is not null) {
var data = (MidiIOErrorNotification) Marshal.PtrToStructure (message, typeof (MidiIOErrorNotification))!;
var data = Marshal.PtrToStructure<MidiIOErrorNotification> (message)!;
eio (client, new IOErrorEventArgs (new MidiDevice (data.DeviceRef), data.ErrorCode));
}
break;

Просмотреть файл

@ -159,7 +159,7 @@ namespace CoreMidi {
using (var data = Runtime.GetNSObject<NSData> (ret)) {
if (data is null)
return null;
var typeSize = Marshal.SizeOf (typeof (MidiThruConnectionRef));
var typeSize = Marshal.SizeOf<MidiThruConnectionRef> ();
var totalObjs = (int) data.Length / typeSize;
if (totalObjs == 0)
return null;

Просмотреть файл

@ -292,11 +292,11 @@ namespace CoreMidi {
internal void ReadStruct (NSData data)
{
IntPtr buffer = data.Bytes;
connectionParams = (MidiThruConnectionParamsStruct) Marshal.PtrToStructure (buffer, typeof (MidiThruConnectionParamsStruct))!;
connectionParams = Marshal.PtrToStructure<MidiThruConnectionParamsStruct> (buffer)!;
// Put ourselves at the end of the static struct in case we need to fetch the dynamic part of the struct
IntPtr bufferEnd = IntPtr.Add (buffer, Marshal.SizeOf (typeof (MidiThruConnectionParamsStruct)));
var controlsSize = Marshal.SizeOf (typeof (MidiControlTransform));
IntPtr bufferEnd = IntPtr.Add (buffer, Marshal.SizeOf<MidiThruConnectionParamsStruct> ());
var controlsSize = Marshal.SizeOf<MidiControlTransform> ();
if (connectionParams.NumControlTransforms == 0)
Controls = null;
@ -345,18 +345,18 @@ namespace CoreMidi {
connectionParams.NumControlTransforms = Controls is not null ? (ushort) Controls.Length : (ushort) 0;
connectionParams.NumMaps = Maps is not null ? (ushort) Maps.Length : (ushort) 0;
var paramsSize = Marshal.SizeOf (typeof (MidiThruConnectionParamsStruct));
var controlsSize = Marshal.SizeOf (typeof (MidiControlTransform));
var paramsSize = Marshal.SizeOf<MidiThruConnectionParamsStruct> ();
var controlsSize = Marshal.SizeOf<MidiControlTransform> ();
// Get the full size of the struct, static + dynamic parts
var fullSize = paramsSize +
(Controls is null ? 0 : controlsSize * Controls.Length) +
(Maps is null ? 0 : 128 * Maps.Length);
var buffer = Marshal.AllocHGlobal (fullSize);
var bufferEnd = IntPtr.Add (buffer, Marshal.SizeOf (typeof (MidiThruConnectionParamsStruct)));
var bufferEnd = IntPtr.Add (buffer, Marshal.SizeOf<MidiThruConnectionParamsStruct> ());
try {
// Copy static sized struct
Marshal.StructureToPtr (connectionParams, buffer, false);
Marshal.StructureToPtr<MidiThruConnectionParamsStruct> (connectionParams, buffer, false);
if (connectionParams.NumControlTransforms > 0) {
unsafe {

Просмотреть файл

@ -108,7 +108,7 @@ namespace CoreServices
return Guid.Empty;
}
return (Guid)Marshal.PtrToStructure (uuidRef, typeof (Guid))!;
return Marshal.PtrToStructure<Guid> (uuidRef)!;
}
[DllImport (Constants.CoreServicesLibrary)]

Просмотреть файл

@ -226,9 +226,9 @@ namespace CoreText {
if (!value.HasValue)
Adapter.SetValue (Dictionary, CTFontDescriptorAttributeKey.Matrix!, (NSObject?) null);
else {
byte [] data = new byte [sizeof (CGAffineTransform)];
byte [] data = new byte [Marshal.SizeOf<CGAffineTransform> ()];
fixed (byte* p = data) {
Marshal.StructureToPtr (value.Value, (IntPtr) p, false);
Marshal.StructureToPtr<CGAffineTransform> (value.Value, (IntPtr) p, false);
}
Adapter.SetValue (Dictionary, CTFontDescriptorAttributeKey.Matrix!, NSData.FromArray (data));
}

Просмотреть файл

@ -52,13 +52,13 @@ namespace CoreVideo {
#if !COREBUILD
public static CVTime ZeroTime {
get {
return (CVTime) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.CoreVideo.Handle, "kCVZeroTime"), typeof (CVTime))!;
return Marshal.PtrToStructure<CVTime> (Dlfcn.GetIndirect (Libraries.CoreVideo.Handle, "kCVZeroTime"))!;
}
}
public static CVTime IndefiniteTime {
get {
return (CVTime) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.CoreVideo.Handle, "kCVIndefiniteTime"), typeof (CVTime))!;
return Marshal.PtrToStructure<CVTime> (Dlfcn.GetIndirect (Libraries.CoreVideo.Handle, "kCVIndefiniteTime"))!;
}
}
#endif

Просмотреть файл

@ -234,7 +234,19 @@ namespace Foundation {
return value as NSDictionary<TKey, TValue>;
}
protected T? GetStrongDictionary<T> (NSString key) where T : DictionaryContainer
#if NET
protected T? GetStrongDictionary<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T> (NSString key)
#else
protected T? GetStrongDictionary<T> (NSString key)
#endif
where T : DictionaryContainer
{
return GetStrongDictionary (key, dict =>
(T?) Activator.CreateInstance (typeof (T), new object [] { dict }));
}
protected T? GetStrongDictionary<T> (NSString? key, Func<NSDictionary, T?> createStrongDictionary)
where T : DictionaryContainer
{
if (key is null)
throw new ArgumentNullException (nameof (key));
@ -242,9 +254,8 @@ namespace Foundation {
var dict = GetNSDictionary (key);
if (dict is null)
return null;
return (T?) Activator.CreateInstance (typeof (T),
new object [] { dict }
);
return createStrongDictionary (dict);
}
protected NSString? GetNSStringValue (NSString key)

Просмотреть файл

@ -29,6 +29,7 @@
#if MONOMAC
using System;
using System.Diagnostics.CodeAnalysis;
using ObjCRuntime;
@ -52,7 +53,11 @@ namespace Foundation
return GetRootProxy<TProxy> (_GetRootProxy (name, hostName, server));
}
#if NET
static TProxy GetRootProxy<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TProxy> (IntPtr handle) where TProxy : NSObject
#else
static TProxy GetRootProxy<TProxy> (IntPtr handle) where TProxy : NSObject
#endif
{
var result = Runtime.TryGetNSObject (handle) as TProxy;

Просмотреть файл

@ -87,7 +87,7 @@ namespace Foundation {
if (inContextPtr == IntPtr.Zero)
return false;
inContext = (CFStreamClientContext) Marshal.PtrToStructure (inContextPtr, typeof (CFStreamClientContext));
inContext = Marshal.PtrToStructure<CFStreamClientContext> (inContextPtr)!;
if (inContext.Version != 0)
return false;

Просмотреть файл

@ -106,12 +106,12 @@ namespace GameplayKit {
{
var type = typeof (T);
// Vector3 is 12 bytes but vector_float3 is 16
var size = type == typeof (Vector3) ? 16 : Marshal.SizeOf (type);
var size = type == typeof (Vector3) ? 16 : Marshal.SizeOf<T> ();
var length = points.Length * size;
buffer = Marshal.AllocHGlobal (length);
for (int i = 0; i < points.Length; i++)
Marshal.StructureToPtr (points [i], IntPtr.Add (buffer, i * size), false);
Marshal.StructureToPtr<T> (points [i], IntPtr.Add (buffer, i * size), false);
}
}
}

Просмотреть файл

@ -27,13 +27,13 @@ namespace GameplayKit {
if (points is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (points));
var size = Marshal.SizeOf (typeof (Vector2));
var size = Marshal.SizeOf<Vector2> ();
var length = points.Length * size;
var buffer = Marshal.AllocHGlobal (length);
try {
for (int i = 0; i < points.Length; i++)
Marshal.StructureToPtr (points [i], IntPtr.Add (buffer, i * size), false);
Marshal.StructureToPtr<Vector2> (points [i], IntPtr.Add (buffer, i * size), false);
return FromPoints (buffer, (nuint) points.Length);
} finally {
@ -56,12 +56,12 @@ namespace GameplayKit {
ctor_pointer = IntPtr.Zero;
}
var size = Marshal.SizeOf (typeof (Vector2));
var size = Marshal.SizeOf<Vector2> ();
var length = points.Length * size;
var buffer = Marshal.AllocHGlobal (length);
for (int i = 0; i < points.Length; i++)
Marshal.StructureToPtr (points [i], IntPtr.Add (buffer, i * size), false);
Marshal.StructureToPtr<Vector2> (points [i], IntPtr.Add (buffer, i * size), false);
ctor_pointer = buffer;
return ctor_pointer = buffer;

Просмотреть файл

@ -200,7 +200,7 @@ namespace Metal {
var handle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, since it's not possible to use unsafe code to get the address of a generic object.
try {
IntPtr ptr = handle.AddrOfPinnedObject ();
return This.CreateBuffer (ptr, (nuint) (data.Length * Marshal.SizeOf (typeof (T))), options);
return This.CreateBuffer (ptr, (nuint) (data.Length * Marshal.SizeOf<T> ()), options);
} finally {
handle.Free ();
}
@ -215,7 +215,7 @@ namespace Metal {
var handle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, since it's not possible to use unsafe code to get the address of a generic object.
IntPtr ptr = handle.AddrOfPinnedObject ();
return This.CreateBufferNoCopy (ptr, (nuint) (data.Length * Marshal.SizeOf (typeof (T))), options, (pointer, length) => {
return This.CreateBufferNoCopy (ptr, (nuint) (data.Length * Marshal.SizeOf<T> ()), options, (pointer, length) => {
handle.Free ();
deallocator (pointer, length);
});

Просмотреть файл

@ -11,7 +11,7 @@ using ObjCRuntime;
namespace MetalPerformanceShaders {
public partial class MPSImageScale {
static int size_of_scale_transform = Marshal.SizeOf (typeof (MPSScaleTransform));
static int size_of_scale_transform = Marshal.SizeOf<MPSScaleTransform> ();
public virtual MPSScaleTransform? ScaleTransform {
get {

Просмотреть файл

@ -47,7 +47,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new ArgumentOutOfRangeException ($"The '{nameof (values)}' and '{nameof (times)}' arrays must have the same length");
int typeSize = Marshal.SizeOf (typeof (Quaternion));
int typeSize = Marshal.SizeOf<Quaternion> ();
unsafe {
fixed (Quaternion* valuesPtr = values)
@ -64,7 +64,7 @@ namespace ModelIO {
if (values.Length != times.Length)
throw new ArgumentOutOfRangeException ($"The '{nameof (values)}' and '{nameof (times)}' arrays must have the same length");
int typeSize = Marshal.SizeOf (typeof (Quaterniond));
int typeSize = Marshal.SizeOf<Quaterniond> ();
unsafe {
fixed (Quaterniond* valuesPtr = values)

Просмотреть файл

@ -186,7 +186,7 @@ namespace ModelIO {
{
if (array is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (array));
int typeSize = Marshal.SizeOf (typeof (Vector3));
int typeSize = Marshal.SizeOf<Vector3> ();
unsafe {
fixed (Vector3* arrptr = array)
@ -198,7 +198,7 @@ namespace ModelIO {
{
if (array is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (array));
int typeSize = Marshal.SizeOf (typeof (Vector3d));
int typeSize = Marshal.SizeOf<Vector3d> ();
unsafe {
fixed (Vector3d* arrptr = array)
@ -240,7 +240,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
if (times is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
int typeSize = Marshal.SizeOf (typeof (Vector3));
int typeSize = Marshal.SizeOf<Vector3> ();
unsafe {
fixed (Vector3* valuesPtr = values)
@ -254,7 +254,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
if (times is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
int typeSize = Marshal.SizeOf (typeof (Vector3d));
int typeSize = Marshal.SizeOf<Vector3d> ();
unsafe {
fixed (Vector3d* valuesPtr = values)
@ -297,7 +297,7 @@ namespace ModelIO {
{
if (array is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (array));
int typeSize = Marshal.SizeOf (typeof (Quaternion));
int typeSize = Marshal.SizeOf<Quaternion> ();
unsafe {
fixed (Quaternion* arrptr = array)
@ -309,7 +309,7 @@ namespace ModelIO {
{
if (array is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (array));
int typeSize = Marshal.SizeOf (typeof (Quaterniond));
int typeSize = Marshal.SizeOf<Quaterniond> ();
unsafe {
fixed (Quaterniond* arrptr = array)
@ -351,7 +351,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
if (times is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
int typeSize = Marshal.SizeOf (typeof (Quaternion));
int typeSize = Marshal.SizeOf<Quaternion> ();
unsafe {
fixed (Quaternion* valuesPtr = values)
@ -365,7 +365,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (values));
if (times is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
int typeSize = Marshal.SizeOf (typeof (Quaterniond));
int typeSize = Marshal.SizeOf<Quaterniond> ();
unsafe {
fixed (Quaterniond* valuesPtr = values)
@ -466,7 +466,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Vector2));
int typeSize = Marshal.SizeOf<Vector2> ();
unsafe {
fixed (Vector2* valuesPtr = values)
@ -482,7 +482,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Vector2d));
int typeSize = Marshal.SizeOf<Vector2d> ();
unsafe {
fixed (Vector2d* valuesPtr = values)
@ -529,7 +529,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Vector3));
int typeSize = Marshal.SizeOf<Vector3> ();
unsafe {
fixed (Vector3* valuesPtr = values)
@ -545,7 +545,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Vector3d));
int typeSize = Marshal.SizeOf<Vector3d> ();
unsafe {
fixed (Vector3d* valuesPtr = values)
@ -592,7 +592,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Vector4));
int typeSize = Marshal.SizeOf<Vector4> ();
unsafe {
fixed (Vector4* valuesPtr = values)
@ -608,7 +608,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Vector4d));
int typeSize = Marshal.SizeOf<Vector4d> ();
unsafe {
fixed (Vector4d* valuesPtr = values)
@ -655,7 +655,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Matrix4));
int typeSize = Marshal.SizeOf<Matrix4> ();
unsafe {
fixed (Matrix4* valuesPtr = values)
@ -671,7 +671,7 @@ namespace ModelIO {
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (times));
if (values.Length != times.Length)
throw new InvalidOperationException ($"The length of the '{nameof (values)}' array and the '{nameof (times)}' array must match.");
int typeSize = Marshal.SizeOf (typeof (Matrix4d));
int typeSize = Marshal.SizeOf<Matrix4d> ();
unsafe {
fixed (Matrix4d* valuesPtr = values)
@ -714,7 +714,7 @@ namespace ModelIO {
{
if (array is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (array));
int typeSize = Marshal.SizeOf (typeof (Matrix4));
int typeSize = Marshal.SizeOf<Matrix4> ();
unsafe {
fixed (Matrix4* arrptr = array)
@ -726,7 +726,7 @@ namespace ModelIO {
{
if (array is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (array));
int typeSize = Marshal.SizeOf (typeof (Matrix4d));
int typeSize = Marshal.SizeOf<Matrix4d> ();
unsafe {
fixed (Matrix4d* arrptr = array)

Просмотреть файл

@ -447,7 +447,7 @@ namespace ObjCRuntime {
static IntPtr MarshalStructure<T> (T value) where T: struct
{
var rv = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (T)));
var rv = Marshal.AllocHGlobal (Marshal.SizeOf<T> ());
StructureToPtr (value, rv);
return rv;
}

Просмотреть файл

@ -279,7 +279,7 @@ namespace ObjCRuntime {
#if PROFILE
var watch = new Stopwatch ();
#endif
if (options->Size != Marshal.SizeOf (typeof (InitializationOptions))) {
if (options->Size != Marshal.SizeOf<InitializationOptions> ()) {
var msg = $"Version mismatch between the native {ProductName} runtime and {AssemblyName}. Please reinstall {ProductName}.";
NSLog (msg);
#if MONOMAC

Просмотреть файл

@ -356,7 +356,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector2 struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector2 ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector2> ();
#endregion

Просмотреть файл

@ -65,7 +65,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector2d struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector2d ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector2d> ();
#endregion

Просмотреть файл

@ -357,7 +357,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector3d struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector3d ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector3d> ();
#endregion

Просмотреть файл

@ -93,7 +93,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector4 struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector4 ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector4> ();
#endregion

Просмотреть файл

@ -90,7 +90,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector4d struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector4d ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector4d> ();
#endregion

Просмотреть файл

@ -90,7 +90,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector2i struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector2i ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector2i> ();
#endregion

Просмотреть файл

@ -132,7 +132,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector3i struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector3i ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector3i> ();
#endregion

Просмотреть файл

@ -89,7 +89,7 @@ namespace OpenTK {
/// <summary>
/// Defines the size of the Vector4i struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new Vector4i ());
public static readonly int SizeInBytes = Marshal.SizeOf<Vector4i> ();
#endregion

Просмотреть файл

@ -255,7 +255,7 @@ namespace SceneKit {
/// <summary>
/// Defines the size of the SCNVector3 struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new SCNVector3 ());
public static readonly int SizeInBytes = Marshal.SizeOf<SCNVector3> ();
#endregion

Просмотреть файл

@ -123,7 +123,7 @@ namespace SceneKit {
/// <summary>
/// Defines the size of the SCNVector4 struct in bytes.
/// </summary>
public static readonly int SizeInBytes = Marshal.SizeOf (new SCNVector4 ());
public static readonly int SizeInBytes = Marshal.SizeOf<SCNVector4> ();
#endregion

Просмотреть файл

@ -22,7 +22,7 @@ namespace UIKit {
if (automaticInsets is null) {
var lib = Libraries.UIKit.Handle;
var ret = Dlfcn.dlsym (lib, "UIListSeparatorAutomaticInsets");
automaticInsets = (NSDirectionalEdgeInsets) Marshal.PtrToStructure (ret, typeof (NSDirectionalEdgeInsets));
automaticInsets = Marshal.PtrToStructure<NSDirectionalEdgeInsets> (ret)!;
}
return automaticInsets.Value;

Просмотреть файл

@ -175,28 +175,28 @@ namespace UIKit {
#if !COREBUILD
[Field ("UIPointerAccessoryPositionTop", "UIKit")]
public static UIPointerAccessoryPosition Top => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionTop"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition Top => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionTop"))!;
[Field ("UIPointerAccessoryPositionTopRight", "UIKit")]
public static UIPointerAccessoryPosition TopRight => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionTopRight"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition TopRight => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionTopRight"))!;
[Field ("UIPointerAccessoryPositionRight", "UIKit")]
public static UIPointerAccessoryPosition Right => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionRight"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition Right => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionRight"))!;
[Field ("UIPointerAccessoryPositionBottomRight", "UIKit")]
public static UIPointerAccessoryPosition BottomRight => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionBottomRight"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition BottomRight => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionBottomRight"))!;
[Field ("UIPointerAccessoryPositionBottom", "UIKit")]
public static UIPointerAccessoryPosition Bottom => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionBottom"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition Bottom => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionBottom"))!;
[Field ("UIPointerAccessoryPositionBottomLeft", "UIKit")]
public static UIPointerAccessoryPosition BottomLeft => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionBottomLeft"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition BottomLeft => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionBottomLeft"))!;
[Field ("UIPointerAccessoryPositionLeft", "UIKit")]
public static UIPointerAccessoryPosition Left => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionLeft"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition Left => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionLeft"))!;
[Field ("UIPointerAccessoryPositionTopLeft", "UIKit")]
public static UIPointerAccessoryPosition TopLeft => (UIPointerAccessoryPosition) Marshal.PtrToStructure (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionTopLeft"), typeof (UIPointerAccessoryPosition))!;
public static UIPointerAccessoryPosition TopLeft => Marshal.PtrToStructure<UIPointerAccessoryPosition> (Dlfcn.GetIndirect (Libraries.UIKit.Handle, "UIPointerAccessoryPositionTopLeft"))!;
#endif
}
#endif

Просмотреть файл

@ -2016,7 +2016,7 @@ public partial class Generator : IMemberGatherer {
setter = "SetNativeValue ({0}, value)";
} else if (IsDictionaryContainerType (pi.PropertyType) || AttributeManager.HasAttribute<StrongDictionaryAttribute> (pi)) {
var strType = pi.PropertyType.Name;
getter = "GetStrongDictionary<" + strType + ">({0})";
getter = $"GetStrongDictionary<{strType}>({{0}}, (dict) => new {strType} (dict))";
setter = "SetNativeValue ({0}, value.GetDictionary ())";
} else if (IsWrappedType (pi.PropertyType)) {
getter = "Dictionary [{0}] as " + pi.PropertyType;
@ -3753,7 +3753,7 @@ public partial class Generator : IMemberGatherer {
trampoline_info = MakeTrampoline (mi.ReturnType);
} else if (align is not null) {
print ("{0} ret = default({0});", FormatType (mi.DeclaringType, mi.ReturnType));
print ("IntPtr ret_alloced = Marshal.AllocHGlobal (Marshal.SizeOf (typeof ({0})) + {1});", FormatType (mi.DeclaringType, mi.ReturnType), align.Align);
print ("IntPtr ret_alloced = Marshal.AllocHGlobal (Marshal.SizeOf<{0}> () + {1});", FormatType (mi.DeclaringType, mi.ReturnType), align.Align);
print ("IntPtr aligned_ret = new IntPtr (((nint) (ret_alloced + {0}) >> {1}) << {1});", align.Align - 1, align.Bits);
print ("bool aligned_assigned = false;");
} else if (minfo.protocolize) {

Просмотреть файл

@ -131,24 +131,37 @@ namespace Xamarin.Tests {
if (properties is not null) {
Dictionary<string, string>? generatedProps = null;
foreach (var prop in properties) {
if (prop.Value.IndexOfAny (new char [] { ';' }) >= 0) {
// https://github.com/dotnet/msbuild/issues/471
// Escaping the semi colon like the issue suggests at one point doesn't work, because in
// that case MSBuild won't split the string into its parts for tasks that take a string[].
// This means that a task that takes a "string[] RuntimeIdentifiers" will get an array with
// a single element, where that single element is the whole RuntimeIdentifiers string.
// Example task: https://github.com/dotnet/sdk/blob/ffca47e9a36652da2e7041360f2201a2ba197194/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs#L45
// args.Add ($"/p:{prop.Key}=\"{prop.Value}\"");
// Setting a property with a semicolon from the command line doesn't work anymore.
// Ref: https://github.com/dotnet/sdk/issues/27059#issuecomment-1219319513
// So write these properties in a file instead. This is a behavioural difference, because
// they'll be project-specific instead of global, but I don't see a better workaround.
// Some properties must be specified on the command line to work properly ("TargetFrameworks").
// Some tests require certain properties to be specified in a file.
// So we support both, where prefixing a property name with "cmdline:" forces it to be passed on the command line,
// while prefixing it with "file:" forces it to be specified in a file.
// No prefix means the default (which can change): currently on the command line.
var cmdline = true; // default
var key = prop.Key;
var value = prop.Value;
if (key.StartsWith ("file:", StringComparison.Ordinal)) {
key = key.Substring ("file:".Length);
cmdline = false;
} else if (key.StartsWith ("cmdline:", StringComparison.Ordinal)) {
key = key.Substring ("cmdline:".Length);
cmdline = true;
}
if (cmdline) {
if (prop.Value.IndexOfAny (new char [] { ';' }) >= 0) {
// https://github.com/dotnet/msbuild/issues/471
// Escaping the semi colon like the issue suggests at one point doesn't work, because in
// that case MSBuild won't split the string into its parts for tasks that take a string[].
// This means that a task that takes a "string[] RuntimeIdentifiers" will get an array with
// a single element, where that single element is the whole RuntimeIdentifiers string.
// Example task: https://github.com/dotnet/sdk/blob/ffca47e9a36652da2e7041360f2201a2ba197194/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs#L45
args.Add ($"/p:{key}=\"{value}\"");
} else {
args.Add ($"/p:{key}={value}");
}
} else {
if (generatedProps is null)
generatedProps = new Dictionary<string, string> ();
generatedProps.Add (prop.Key, prop.Value);
} else {
args.Add ($"/p:{prop.Key}={prop.Value}");
generatedProps.Add (key, value);
}
}
if (generatedProps is not null) {

Просмотреть файл

@ -438,7 +438,10 @@ namespace Xamarin.Tests {
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["RuntimeIdentifier"] = "maccatalyst-x64";
// Be specific that we want "RuntimeIdentifier" specified on the command line, and "RuntimeIdentifiers" in a file
properties ["file:RuntimeIdentifiers"] = properties ["RuntimeIdentifiers"];
properties.Remove ("RuntimeIdentifiers");
properties ["cmdline:RuntimeIdentifier"] = "maccatalyst-x64";
var rv = DotNet.AssertBuild (project_path, properties);
var warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).ToArray ();
Assert.AreEqual (1, warnings.Length, "Warning Count");
@ -1293,6 +1296,32 @@ namespace Xamarin.Tests {
}
}
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Release")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Debug")]
public void CheckForMacCatalystDefaultEntitlements (ApplePlatform platform, string runtimeIdentifiers, string configuration)
{
var project = "Entitlements";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["Configuration"] = configuration;
DotNet.AssertBuild (project_path, properties);
var executable = GetNativeExecutable (platform, appPath);
var foundEntitlements = TryGetEntitlements (executable, out var entitlements);
Assert.IsTrue (foundEntitlements, "Issues found with Entitlements.");
if (configuration == "Release") {
Assert.IsTrue (entitlements!.Get<PBoolean> ("com.apple.security.app-sandbox")?.Value, "com.apple.security.app-sandbox enlistment was not found in Release configuration.");
Assert.IsNull (entitlements.Get<PBoolean> ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was found in Release configuration.");
} else if (configuration == "Debug") {
Assert.IsTrue (entitlements!.Get<PBoolean> ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was not found in Debug configuration.");
}
}
// [TestCase (ApplePlatform.MacCatalyst, null, "Release")]
[TestCase (ApplePlatform.MacOSX, null, "Release")]
public void NoWarnCodesign (ApplePlatform platform, string runtimeIdentifiers, string configuration)

Просмотреть файл

@ -4,7 +4,9 @@ using System.Linq;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Xamarin.Utils;
using Xamarin.Tests;
namespace Xamarin.MMP.Tests {
public class BindingProjectNoEmbeddingTests {
@ -45,6 +47,7 @@ namespace Xamarin.MMP.Tests {
[TestCase (BindingProjectType.Full, false)]
public void FrameworksEmbeddedProperly (BindingProjectType type, bool useProjectReference)
{
Configuration.AssertDotNetAvailable (); // not really a .NET test, but the logic that builds our native test frameworks is (unintentionally, but untrivially unravelable) .NET-only
MMPTests.RunMMPTest (tmpDir => {
string frameworkPath = FrameworkBuilder.CreateThinFramework (tmpDir);

Просмотреть файл

@ -82,6 +82,7 @@ namespace Xamarin.MMP.Tests {
[TestCase (false, false, false)]
public void ShouldStripUserFramework (bool? strip, bool debugStrips, bool releaseStrips)
{
Configuration.AssertDotNetAvailable (); // not really a .NET test, but the logic that builds our native test frameworks is (unintentionally, but untrivially unravelable) .NET-only
MMPTests.RunMMPTest (tmpDir => {
var frameworkPath = FrameworkBuilder.CreateFatFramework (tmpDir);
TI.UnifiedTestConfig test = CreateStripTestConfig (strip, tmpDir, $"--native-reference={frameworkPath}");
@ -138,6 +139,7 @@ namespace Xamarin.MMP.Tests {
[TestCase (true)]
public void ThirdPartyLibrary_WithIncorrectBitness_ShouldWarnOnRelease (bool sixtyFourBits)
{
Configuration.AssertDotNetAvailable (); // not really a .NET test, but the logic that builds our native test frameworks is (unintentionally, but untrivially unravelable) .NET-only
MMPTests.RunMMPTest (tmpDir => {
var frameworkPath = FrameworkBuilder.CreateFatFramework (tmpDir);
@ -160,6 +162,7 @@ namespace Xamarin.MMP.Tests {
[TestCase]
public void ThirdPartyLibrary_WithCorrectBitness_ShouldNotStripOrWarn ()
{
Configuration.AssertDotNetAvailable (); // not really a .NET test, but the logic that builds our native test frameworks is (unintentionally, but untrivially unravelable) .NET-only
MMPTests.RunMMPTest (tmpDir => {
var frameworkPath = FrameworkBuilder.CreateThinFramework (tmpDir);

Просмотреть файл

@ -24,7 +24,8 @@ namespace Xamarin.MacDev.Tasks {
};
RunMake (Path.Combine (Configuration.RootPath, "tests", "test-libraries"), environment: env);
RunMake (Path.Combine (Configuration.RootPath, "tests", "common", "TestProjects", "ComplexAssembly"), environment: env);
if (Configuration.include_dotnet)
RunMake (Path.Combine (Configuration.RootPath, "tests", "common", "TestProjects", "ComplexAssembly"), environment: env);
}
static void RunMake (string directory, Dictionary<string, string> environment = null)
@ -115,6 +116,7 @@ namespace Xamarin.MacDev.Tasks {
[Test]
public void TestPEAssembly ()
{
Configuration.AssertDotNetAvailable ();
var complexAssemblyPath = Path.Combine (Configuration.RootPath, "tests", "common", "TestProjects", "ComplexAssembly", "bin", "Debug", Configuration.DotNetTfm);
var complexFiles = new string [] {
"ComplexAssembly.dll",

Просмотреть файл

@ -982,6 +982,7 @@ public struct FooF { public NSObject Obj; }
[TestCase (Profile.iOS, "iOS", MTouchLinker.LinkAll)]
public void MT4162_dotnet (Profile profile, string name, MTouchLinker linker)
{
Configuration.AssertDotNetAvailable ();
var code = @"
[SupportedOSPlatform (""ios77.0"")]
[SupportedOSPlatform (""tvos77.0"")]

Просмотреть файл

@ -17,6 +17,7 @@ mkdir -p "$DIR"
make test.config
cat test.config
INCLUDE_XAMARIN_LEGACY=$(grep ^INCLUDE_XAMARIN_LEGACY= test.config | sed 's/.*=//')
ENABLE_DOTNET=$(grep ^ENABLE_DOTNET= test.config | sed 's/.*=//')
INCLUDE_MAC=$(grep ^INCLUDE_MAC= test.config | sed 's/.*=//')
INCLUDE_MACCATALYST=$(grep ^INCLUDE_MACCATALYST= test.config | sed 's/.*=//')
XCODE_DEVELOPER_ROOT=$(grep ^XCODE_DEVELOPER_ROOT= test.config | sed 's/.*=//')
@ -41,14 +42,16 @@ TEST_SUITE_DEPENDENCIES+=(EmbeddedResources)
TEST_SUITE_DEPENDENCIES+=(fsharplibrary)
TEST_SUITE_DEPENDENCIES+=(BundledResources)
for dep in "${TEST_SUITE_DEPENDENCIES[@]}"; do
if test -n "$INCLUDE_MAC"; then
make -C "$dep"/dotnet/macOS build
fi
if test -n "$INCLUDE_MACCATALYST"; then
make -C "$dep"/dotnet/MacCatalyst build
fi
done
if test -n "$ENABLE_DOTNET"; then
for dep in "${TEST_SUITE_DEPENDENCIES[@]}"; do
if test -n "$INCLUDE_MAC"; then
make -C "$dep"/dotnet/macOS build
fi
if test -n "$INCLUDE_MACCATALYST"; then
make -C "$dep"/dotnet/MacCatalyst build
fi
done
fi
TEST_SUITES+=(build-dontlink)
TEST_SUITES+=(build-linksdk)
@ -72,10 +75,12 @@ if test -n "$INCLUDE_XAMARIN_LEGACY"; then
done
fi
for app in linker/*/*/dotnet/*/bin/*/*/*/*.app */dotnet/*/bin/*/*/*/*.app; do
mkdir -p "$DIR/tests/$app"
$CP -R "$app" "$DIR/tests/$app/.."
done
if test -n "$ENABLE_DOTNET"; then
for app in linker/*/*/dotnet/*/bin/*/*/*/*.app */dotnet/*/bin/*/*/*/*.app; do
mkdir -p "$DIR/tests/$app"
$CP -R "$app" "$DIR/tests/$app/.."
done
fi
$CP -p packaged-macos-tests.mk "$DIR/tests"
$CP -p run-with-timeout.* "$DIR/tests"

Просмотреть файл

@ -151,50 +151,67 @@ build-mac-dotnet-x64-$(1): .stamp-dotnet-dependency-macOS
$$(Q) $$(MAKE) -C "$(1)/dotnet/macOS" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=osx-x64
exec-mac-dotnet-x64-$(1):
ifdef ENABLE_DOTNET
@echo " Executing the '$(1)' test for macOS/.NET (x64) "
$$(Q) $(RUN_WITH_TIMEOUT$(3)) "./$(1)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-x64/$(2).app/Contents/MacOS/$(2)"
else
$(Q) echo "Not executing $@, because .NET is not enabled"
endif
# macOS/.NET/arm64
build-mac-dotnet-arm64-$(1): .stamp-dotnet-dependency-macOS
$$(Q) $$(MAKE) -C "$(1)/dotnet/macOS" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=osx-arm64
exec-mac-dotnet-arm64-$(1):
ifdef ENABLE_DOTNET
ifeq ($(IS_APPLE_SILICON),1)
@echo " Executing the '$(1)' test for macOS/.NET (arm64) "
$$(Q) $(RUN_WITH_TIMEOUT$(3)) "./$(1)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-arm64/$(2).app/Contents/MacOS/$(2)"
else
@echo "⚠️ Not executing the '$(1)' test for macOS/.NET (arm64) - not executing on Apple Silicon ⚠️"
endif
else
$(Q) echo "Not executing $@, because .NET is not enabled"
endif
# MacCatalyst/.NET/x64
build-maccatalyst-dotnet-x64-$(1): .stamp-dotnet-dependency-MacCatalyst
$$(Q_BUILD) $$(MAKE) -C "$(1)/dotnet/MacCatalyst" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=maccatalyst-x64
exec-maccatalyst-dotnet-x64-$(1):
ifdef ENABLE_DOTNET
ifeq ($(SUPPORTS_MACCATALYST),1)
@echo " Executing the '$(1)' test for Mac Catalyst/.NET (x64) "
$$(Q) $(RUN_WITH_TIMEOUT$(3)) "./$(1)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-x64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
else
@echo "⚠️ Not executing the '$(1)' test for Mac Catalyst/.NET (x64) - macOS version $(MACOS_VERSION) is too old ⚠️"
endif
else
$(Q) echo "Not executing $@, because .NET is not enabled"
endif
# MacCatalyst/.NET/arm64
build-maccatalyst-dotnet-arm64-$(1):.stamp-dotnet-dependency-MacCatalyst
$$(Q) $$(MAKE) -C "$(1)/dotnet/MacCatalyst" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=maccatalyst-arm64
exec-maccatalyst-dotnet-arm64-$(1):
ifdef ENABLE_DOTNET
ifeq ($(IS_APPLE_SILICON),1)
@echo " Executing the '$(1)' test for Mac Catalyst/.NET (arm64) "
$$(Q) $(RUN_WITH_TIMEOUT$(3)) "./$(1)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-arm64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
else
@echo "⚠️ Not executing the '$(1)' test for Mac Catalyst/.NET (arm64) - not executing on Apple Silicon ⚠️"
endif
else
$(Q) echo "Not executing $@, because .NET is not enabled"
endif
build-$(1): .stamp-nuget-restore-mac
$$(Q) rm -f ".$$@-failure.stamp"
ifdef INCLUDE_XAMARIN_LEGACY
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-legacy-$(1) || echo "build-legacy-$(1) failed" >> ".$$@-failure.stamp"
endif
ifdef ENABLE_DOTNET
ifdef INCLUDE_MAC
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-mac-dotnet-x64-$(1) || echo "build-mac-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-mac-dotnet-arm64-$(1) || echo "build-mac-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
@ -202,6 +219,7 @@ endif
ifdef INCLUDE_MACCATALYST
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-maccatalyst-dotnet-x64-$(1) || echo "build-maccatalyst-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-maccatalyst-dotnet-arm64-$(1) || echo "build-maccatalyst-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
endif
endif
$$(Q) if test -e ".$$@-failure.stamp"; then cat ".$$@-failure.stamp"; rm ".$$@-failure.stamp"; exit 1; fi
@ -210,6 +228,7 @@ exec-$(1):
ifdef INCLUDE_XAMARIN_LEGACY
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-legacy-$(1) || echo "exec-legacy-$(1) failed" >> ".$$@-failure.stamp"
endif
ifdef ENABLE_DOTNET
ifdef INCLUDE_MAC
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-mac-dotnet-x64-$(1) || echo "exec-mac-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-mac-dotnet-arm64-$(1) || echo "exec-mac-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
@ -217,6 +236,7 @@ endif
ifdef INCLUDE_MACCATALYST
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-maccatalyst-dotnet-x64-$(1) || echo "exec-maccatalyst-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-maccatalyst-dotnet-arm64-$(1) || echo "exec-maccatalyst-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
endif
endif
$$(Q) if test -e ".$$@-failure.stamp"; then cat ".$$@-failure.stamp"; rm ".$$@-failure.stamp"; exit 1; fi
endef
@ -276,6 +296,7 @@ build-$(1): .stamp-nuget-restore-mac
ifdef INCLUDE_XAMARIN_LEGACY
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-legacy-$(1) || echo "build-legacy-$(1) failed" >> ".$$@-failure.stamp"
endif
ifdef ENABLE_DOTNET
ifdef INCLUDE_MAC
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-mac-dotnet-x64-$(1) || echo "build-mac-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-mac-dotnet-arm64-$(1) || echo "build-mac-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
@ -283,6 +304,7 @@ endif
ifdef INCLUDE_MACCATALYST
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-maccatalyst-dotnet-x64-$(1) || echo "build-maccatalyst-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk build-maccatalyst-dotnet-arm64-$(1) || echo "build-maccatalyst-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
endif
endif
$$(Q) if test -e ".$$@-failure.stamp"; then cat ".$$@-failure.stamp"; rm ".$$@-failure.stamp"; exit 1; fi
@ -291,6 +313,7 @@ exec-$(1):
ifdef INCLUDE_XAMARIN_LEGACY
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-legacy-$(1) || echo "exec-legacy-$(1) failed" >> ".$$@-failure.stamp"
endif
ifdef ENABLE_DOTNET
ifdef INCLUDE_MAC
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-mac-dotnet-x64-$(1) || echo "exec-mac-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-mac-dotnet-arm64-$(1) || echo "exec-mac-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
@ -298,6 +321,7 @@ endif
ifdef INCLUDE_MACCATALYST
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-maccatalyst-dotnet-x64-$(1) || echo "exec-maccatalyst-dotnet-x64-$(1) failed" >> ".$$@-failure.stamp"
$$(Q) $$(MAKE) -f packaged-macos-tests.mk exec-maccatalyst-dotnet-arm64-$(1) || echo "exec-maccatalyst-dotnet-arm64-$(1) failed" >> ".$$@-failure.stamp"
endif
endif
$$(Q) if test -e ".$$@-failure.stamp"; then cat ".$$@-failure.stamp"; rm ".$$@-failure.stamp"; exit 1; fi
endef

Просмотреть файл

@ -197,7 +197,9 @@ ZIPPED_TARGETS += .libs/$(1).xcframework.zip
all-local:: .libs/$(1).xcframework.stamp
endef
ifdef ENABLE_DOTNET
$(foreach name,$(NAMES),$(eval $(call XCFrameworkTemplate,$(name))))
endif
zip: $(ZIPPED_TARGETS)
all-local:: $(ZIPPED_TARGETS)

Просмотреть файл

@ -24,4 +24,6 @@ $(INSTALLED_PACKAGE): .libs/DynamicLibrariesInRuntimesNativeDirectory.nupkg
mkdir -p $(abspath $(NUGET_TEST_FEED))
nuget add "$<" -source $(abspath $(NUGET_TEST_FEED)) -NonInteractive
ifdef ENABLE_DOTNET
all-local:: $(INSTALLED_PACKAGE)
endif

Просмотреть файл

@ -24,4 +24,6 @@ $(INSTALLED_PACKAGE): .libs/FrameworksInRuntimesNativeDirectory.nupkg
mkdir -p $(abspath $(NUGET_TEST_FEED))
nuget add "$<" -source $(abspath $(NUGET_TEST_FEED)) -NonInteractive
ifdef ENABLE_DOTNET
all-local:: $(INSTALLED_PACKAGE)
endif

Просмотреть файл

@ -228,7 +228,7 @@ namespace Xharness.Jenkins {
TestName = "DotNet tests",
Filter = "Category!=Windows",
Timeout = TimeSpan.FromMinutes (360),
Ignored = !TestSelection.IsEnabled (TestLabel.DotnetTest),
Ignored = !TestSelection.IsEnabled (TestLabel.DotnetTest) || !TestSelection.IsEnabled (PlatformLabel.Dotnet),
};
Tasks.Add (runDotNetTests);

Просмотреть файл

@ -20,7 +20,7 @@ namespace Xharness.Jenkins {
public IEnumerator<RunTestTask> GetEnumerator ()
{
var netstandard2Project = new TestProject (TestLabel.Msbuild, Path.GetFullPath (Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.MacDev.Tasks.Tests", "Xamarin.MacDev.Tasks.Tests.csproj"))) {
IsDotNetProject = true,
IsDotNetProject = false,
};
var env = new Dictionary<string, string>
{
@ -50,7 +50,7 @@ namespace Xharness.Jenkins {
yield return nunitExecutioniOSMSBuild;
var msbuildIntegrationTestsProject = new TestProject (TestLabel.Msbuild, Path.GetFullPath (Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.MacDev.Tests", "Xamarin.MacDev.Tests.csproj"))) {
IsDotNetProject = true,
IsDotNetProject = false,
};
var buildiOSMSBuildIntegration = new MSBuildTask (jenkins: jenkins, testProject: msbuildIntegrationTestsProject, processManager: processManager) {
SpecifyPlatform = false,
@ -146,7 +146,7 @@ namespace Xharness.Jenkins {
Platform = TestPlatform.iOS,
TestName = "Cecil-based tests",
Timeout = TimeSpan.FromMinutes (5),
Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Cecil),
Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Cecil) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Dotnet),
};
yield return runCecilTests;

Просмотреть файл

@ -32,8 +32,8 @@ endif
endif
endif
MONO_API_INFO = $(API_TOOLS_PATH)/mono-api-info/bin/Debug/net6.0/mono-api-info.dll
MONO_API_HTML = $(API_TOOLS_PATH)/mono-api-html/bin/Debug/net6.0/mono-api-html.dll
MONO_API_INFO = $(API_TOOLS_PATH)/mono-api-info/bin/Debug/$(DOTNET_TFM)/mono-api-info.dll
MONO_API_HTML = $(API_TOOLS_PATH)/mono-api-html/bin/Debug/$(DOTNET_TFM)/mono-api-html.dll
MONO_BUILD = $(SYSTEM_MONO)
MONO_API_INFO_EXEC = $(DOTNET) --roll-forward Major $(MONO_API_INFO) --ignore-inherited-interfaces

Просмотреть файл

@ -2901,6 +2901,24 @@ namespace Registrar {
}
#endif
// Xcode 15 removed NewsstandKit
if (Driver.XcodeVersion.Major >= 15) {
if (IsTypeCore (@class, "NewsstandKit")) {
exceptions.Add (ErrorHelper.CreateWarning (4178, $"The class '{@class.Type.FullName}' will not be registered because the NewsstandKit framework has been removed from the {App.Platform} SDK."));
continue;
}
if (@class.Type.Is ("PassKit", "PKDisbursementAuthorizationControllerDelegate")) {
exceptions.Add (ErrorHelper.CreateWarning (4189, $"The class '{@class.Type.FullName}' will not be registered it has been removed from the {App.Platform} SDK."));
continue;
}
if (@class.Type.Is ("PassKit", "PKDisbursementAuthorizationController")) {
exceptions.Add (ErrorHelper.CreateWarning (4189, $"The class '{@class.Type.FullName}' will not be registered it has been removed from the {App.Platform} SDK."));
continue;
}
}
if (@class.IsFakeProtocol)
continue;

Просмотреть файл

@ -39,6 +39,15 @@ fi
# Start working
make global.json
# Check if .NET is even enabled
var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=ENABLE_DOTNET)
ENABLE_DOTNET=${var#*=}
if test -z "$ENABLE_DOTNET"; then
echo "Not installing anything, because .NET is not enabled."
exit 0
fi
make -C builds dotnet
var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=DOTNET)

Просмотреть файл

@ -30,7 +30,7 @@ steps:
- bash: $(Build.SourcesDirectory)/xamarin-macios/tools/devops/automation/scripts/bash/build-nugets.sh
displayName: 'Build Nugets'
condition: and(succeeded(), contains(variables['configuration.BuildNugets'], 'True'))
condition: and(succeeded(), contains(variables['configuration.BuildNugets'], 'True'), ne(variables['ENABLE_DOTNET'],''))
continueOnError: true # should not stop the build since is not official just yet.
timeoutInMinutes: 180
@ -48,7 +48,7 @@ steps:
targetPath: $(Build.SourcesDirectory)/xamarin-macios/_build/nupkgs/bar-manifests
artifactName: '${{ parameters.uploadPrefix }}AssetManifests'
continueOnError: true
condition: and(succeededOrFailed(), contains(variables['configuration.BuildNugets'], 'True'))
condition: and(succeededOrFailed(), contains(variables['configuration.BuildNugets'], 'True'), ne(variables['ENABLE_DOTNET'],''))
- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact: build-binlogs'
@ -56,4 +56,4 @@ steps:
targetPath: $(Build.ArtifactStagingDirectory)/build-binlogs
artifactName: ${{ parameters.uploadPrefix }}build-binlogs-$(Build.BuildId)-$(System.JobAttempt)
continueOnError: true
condition: and(succeededOrFailed(), contains(variables['configuration.BuildNugets'], 'True'))
condition: and(succeededOrFailed(), contains(variables['configuration.BuildNugets'], 'True'), ne(variables['ENABLE_DOTNET'],''))

Просмотреть файл

@ -40,9 +40,28 @@ stages:
condition: and(succeeded(), eq(dependencies.build_packages.outputs['configure.decisions.RUN_WINDOWS_TESTS'], 'true'))
jobs:
- job: configure
displayName: 'Configure build'
pool:
vmImage: windows-latest
variables:
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
isScheduled: $[eq(variables['Build.Reason'], 'Schedule')]
steps:
- template: ../common/configure.yml
parameters:
repositoryAlias: ${{ parameters.repositoryAlias }}
commit: ${{ parameters.commit }}
uploadArtifacts: false
- job: mac_reservation
dependsOn:
- configure
displayName: "Reserve bot for tests"
timeoutInMinutes: 1000
condition: ne(dependencies.configure.outputs['configure_platforms.ENABLE_DOTNET'],'')
workspace:
clean: all
pool:
@ -61,8 +80,10 @@ stages:
- job: run_tests
dependsOn:
- mac_reservation
- configure
displayName: 'Dotnet tests'
timeoutInMinutes: 1000
condition: ne(dependencies.configure.outputs['configure_platforms.ENABLE_DOTNET'],'')
workspace:
clean: all

Просмотреть файл

@ -498,6 +498,19 @@ namespace Xamarin.Linker {
}
}
public MethodReference DynamicDependencyAttribute_ctor__String_String_String {
get {
return GetMethodReference (CorlibAssembly,
System_Diagnostics_CodeAnalysis_DynamicDependencyAttribute,
".ctor",
".ctor(String,String,String)",
isStatic: false,
System_String,
System_String,
System_String);
}
}
public MethodReference RuntimeTypeHandle_Equals {
get {
if (configuration.Application.XamarinRuntime == XamarinRuntime.MonoVM) {
@ -1246,12 +1259,27 @@ namespace Xamarin.Linker {
public CustomAttribute CreateDynamicDependencyAttribute (string memberSignature, TypeDefinition type)
{
if (type.HasGenericParameters) {
var typeName = Xamarin.Utils.DocumentationComments.GetSignature (type);
var assemblyName = type.Module.Assembly.Name.Name;
return CreateDynamicDependencyAttribute (memberSignature, typeName, assemblyName);
}
var attribute = new CustomAttribute (DynamicDependencyAttribute_ctor__String_Type);
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_String, memberSignature));
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_Type, type));
return attribute;
}
public CustomAttribute CreateDynamicDependencyAttribute (string memberSignature, string typeName, string assemblyName)
{
var attribute = new CustomAttribute (DynamicDependencyAttribute_ctor__String_String_String);
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_String, memberSignature));
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_String, typeName));
attribute.ConstructorArguments.Add (new CustomAttributeArgument (System_String, assemblyName));
return attribute;
}
public CustomAttribute CreateDynamicDependencyAttribute (DynamicallyAccessedMemberTypes memberTypes, TypeDefinition type)
{
var attribute = new CustomAttribute (DynamicDependencyAttribute_ctor__DynamicallyAccessedMemberTypes_Type);

Просмотреть файл

@ -24,6 +24,7 @@ namespace Mono.Tuner {
public abstract class ApplyPreserveAttributeBase : ConfigurationAwareSubStep {
AppBundleRewriter? abr;
Queue<Action> deferredActions = new ();
protected override string Name { get => "Apply Preserve Attribute"; }
@ -32,16 +33,7 @@ namespace Mono.Tuner {
// set 'removeAttribute' to true if you want the preserved attribute to be removed from the final assembly
protected abstract bool IsPreservedAttribute (ICustomAttributeProvider provider, CustomAttribute attribute, out bool removeAttribute);
public override SubStepTargets Targets {
get {
return SubStepTargets.Type
| SubStepTargets.Field
| SubStepTargets.Method
| SubStepTargets.Property
| SubStepTargets.Event
| SubStepTargets.Assembly;
}
}
public override SubStepTargets Targets => SubStepTargets.Assembly;
public override void Initialize (LinkContext context)
{
@ -51,6 +43,51 @@ namespace Mono.Tuner {
abr = Configuration.AppBundleRewriter;
}
protected override void Process (AssemblyDefinition assembly)
{
BrowseTypes (assembly.MainModule.Types);
ProcessDeferredActions ();
}
void BrowseTypes (IEnumerable<TypeDefinition> types)
{
foreach (TypeDefinition type in types) {
ProcessType (type);
if (type.HasFields) {
foreach (FieldDefinition field in type.Fields)
ProcessField (field);
}
if (type.HasMethods) {
foreach (MethodDefinition method in type.Methods)
ProcessMethod (method);
}
if (type.HasProperties) {
foreach (PropertyDefinition property in type.Properties)
ProcessProperty (property);
}
if (type.HasEvents) {
foreach (EventDefinition @event in type.Events)
ProcessEvent (@event);
}
if (type.HasNestedTypes) {
BrowseTypes (type.NestedTypes);
}
}
}
void ProcessDeferredActions ()
{
while (deferredActions.Count > 0) {
var action = deferredActions.Dequeue ();
action.Invoke ();
}
}
public override bool IsActiveFor (AssemblyDefinition assembly)
{
return Annotations.GetAction (assembly) == AssemblyAction.Link;
@ -142,7 +179,12 @@ namespace Mono.Tuner {
void PreserveUnconditional (IMetadataTokenProvider provider)
{
Annotations.Mark (provider);
AddDynamicDependencyAttribute (provider);
// We want to add a dynamic dependency attribute to preserve methods and fields
// but not to preserve types while we're marking the chain of declaring types.
if (provider is not TypeDefinition) {
AddDynamicDependencyAttribute (provider);
}
var member = provider as IMemberDefinition;
if (member is null || member.DeclaringType is null)
@ -205,13 +247,7 @@ namespace Mono.Tuner {
MethodDefinition GetOrCreateModuleConstructor (ModuleDefinition @module)
{
var moduleType = @module.GetModuleType ();
var moduleConstructor = moduleType.GetTypeConstructor ();
if (moduleConstructor is null) {
moduleConstructor = moduleType.AddMethod (".cctor", MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName | MethodAttributes.Static, abr!.System_Void);
moduleConstructor.CreateBody (out var il);
il.Emit (OpCodes.Ret);
}
return moduleConstructor;
return GetOrCreateStaticConstructor (moduleType);
}
void AddDynamicDependencyAttribute (TypeDefinition type, bool allMembers)
@ -234,8 +270,7 @@ namespace Mono.Tuner {
if (abr is null)
return;
// I haven't found a way to express a conditional Preserve attribute using DynamicDependencyAttribute :/
ErrorHelper.Warning (2112, Errors.MX2112 /* Unable to apply the conditional [Preserve] attribute on the member {0} */, forMethod.FullName);
deferredActions.Enqueue (() => AddDynamicDependencyAttributeToStaticConstructor (onType, forMethod));
}
void AddDynamicDependencyAttribute (IMetadataTokenProvider provider)
@ -258,5 +293,34 @@ namespace Mono.Tuner {
abr.ClearCurrentAssembly ();
}
void AddDynamicDependencyAttributeToStaticConstructor (TypeDefinition onType, MethodDefinition forMethod)
{
if (abr is null)
return;
abr.ClearCurrentAssembly ();
abr.SetCurrentAssembly (onType.Module.Assembly);
var cctor = GetOrCreateStaticConstructor (onType);
var signature = DocumentationComments.GetSignature (forMethod);
var attrib = abr.CreateDynamicDependencyAttribute (signature, onType);
cctor.CustomAttributes.Add (attrib);
Annotations.AddPreservedMethod (onType, cctor);
abr.ClearCurrentAssembly ();
}
MethodDefinition GetOrCreateStaticConstructor (TypeDefinition type)
{
var staticCtor = type.GetTypeConstructor ();
if (staticCtor is null) {
staticCtor = type.AddMethod (".cctor", MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName | MethodAttributes.Static, abr!.System_Void);
staticCtor.CreateBody (out var il);
il.Emit (OpCodes.Ret);
}
return staticCtor;
}
}
}

Просмотреть файл

@ -28,7 +28,7 @@ namespace Xamarin.Utils {
public static string GetSignature (TypeDefinition type)
{
if (type.IsNested)
return type.Name;
return type.FullName.Replace ('/', '.');
return type.FullName;
}
@ -41,6 +41,11 @@ namespace Xamarin.Utils {
{
var sb = new StringBuilder ();
sb.Append (method.Name.Replace ('.', '#'));
if (method.HasGenericParameters) {
sb.Append ($"``{method.GenericParameters.Count}");
}
sb.Append ('(');
for (var i = 0; i < method.Parameters.Count; i++) {
if (i > 0)
@ -74,6 +79,17 @@ namespace Xamarin.Utils {
return;
}
if (type is GenericParameter gp) {
if (gp.Type == GenericParameterType.Type) {
sb.Append ('`');
} else {
sb.Append ("``");
}
sb.Append (gp.Position.ToString ());
return;
}
sb.Append (type.FullName.Replace ('/', '.'));
}
}

20
tools/mtouch/Errors.designer.cs сгенерированный
Просмотреть файл

@ -3066,7 +3066,7 @@ namespace Xamarin.Bundler {
}
/// <summary>
/// Looks up a localized string similar to The class &apos;{0}&apos; will not be registered because the WatchKit framework has been removed from the iOS SDK.
/// Looks up a localized string similar to The class &apos;{0}&apos; will not be registered because the {1} framework has been removed from the {2} SDK.
/// .
/// </summary>
public static string MT4178 {
@ -4003,15 +4003,6 @@ namespace Xamarin.Bundler {
}
}
/// <summary>
/// Looks up a localized string similar to Unable to apply the conditional [Preserve] attribute on the member {0}..
/// </summary>
public static string MX2112 {
get {
return ResourceManager.GetString("MX2112", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Could not {0} the assembly &apos;{1}&apos;
/// .
@ -4050,6 +4041,15 @@ namespace Xamarin.Bundler {
}
}
/// <summary>
/// Looks up a localized string similar to The class &apos;{0}&apos; will not be registered because it has been removed from the {1} SDK..
/// </summary>
public static string MX4189 {
get {
return ResourceManager.GetString("MX4189", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The native linker failed to execute: {0}. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new
/// .

Просмотреть файл

@ -1346,11 +1346,6 @@
</value>
</data>
<data name="MX2112" xml:space="preserve">
<!-- This is a warning -->
<value>Unable to apply the conditional [Preserve] attribute on the member {0}.</value>
</data>
<!-- 2200 -> 2299 is used by/reserved for ExceptionalSubStep subclasses in the linker -->
<!-- 220x: PreserveSmartEnumConversionsSubStep -->
<!-- 221x: RemoveBitcodeIncompatibleCodeStep -->
@ -1912,7 +1907,7 @@
</data>
<data name="MT4178" xml:space="preserve">
<value>The class '{0}' will not be registered because the WatchKit framework has been removed from the iOS SDK.
<value>The class '{0}' will not be registered because the {1} framework has been removed from the {2} SDK.
</value>
</data>
@ -1943,6 +1938,10 @@
<value>Unable to compute the block signature for the type '{0}': {1}</value>
</data>
<data name="MX4189" xml:space="preserve">
<value>The class '{0}' will not be registered because it has been removed from the {1} SDK.</value>
</data>
<data name="MT5101" xml:space="preserve">
<value>Missing '{0}' compiler. Please install Xcode 'Command-Line Tools' component
</value>

Просмотреть файл

@ -2,7 +2,7 @@ TOP=../..
include $(TOP)/Make.config
ifdef INCLUDE_IOS
all-local:: nnyeah/bin/Debug/net6.0/nnyeah.dll
all-local:: nnyeah/bin/Debug/$(DOTNET_TFM)/nnyeah.dll
install-local:: all-local
endif
@ -20,14 +20,14 @@ $(IOS_DLL):
run-tests:: ./nupkg/nnyeah.$(NUPKG_VERSION).nupkg
$(DOTNET) test tests/nnyeah-tests.csproj $(TEST_FILTER)
nnyeah/bin/Debug/net6.0/nnyeah.dll: $(IOS_DLL) $(wildcard **/*.cs) $(wildcard **/*.csproj) $(wildcard *.sln)
nnyeah/bin/Debug/$(DOTNET_TFM)/nnyeah.dll: $(IOS_DLL) $(wildcard **/*.cs) $(wildcard **/*.csproj) $(wildcard *.sln)
$(Q_BUILD) $(DOTNET) build "/bl:$@.binlog" /restore $(MSBUILD_VERBOSITY) $(wildcard *.sln)
clean:
$(Q_BUILD) $(DOTNET) build "/bl:$@.binlog" /restore $(MSBUILD_VERBOSITY) /t:Clean $(wildcard *.sln)
./nupkg/nnyeah.$(NUPKG_VERSION).nupkg: nnyeah/bin/Debug/net6.0/nnyeah.dll
./nupkg/nnyeah.$(NUPKG_VERSION).nupkg: nnyeah/bin/Debug/$(DOTNET_TFM)/nnyeah.dll
$(Q) $(DOTNET) pack nnyeah/nnyeah.csproj
$(Q) mkdir -p nupkg
$(Q) cp nnyeah/bin/Debug/nnyeah.$(NUPKG_VERSION).nupkg ./nupkg/nnyeah.$(NUPKG_VERSION).nupkg

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
<RootNamespace>Microsoft.MaciOS.Nnyeah</RootNamespace>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.MaciOS.Nnyeah.Tests.Integration {
[TestFixture]
public class IntegrationExamples {
string IntegrationRoot => Path.Combine (Configuration.SourceRoot, "tools", "nnyeah", "integration");
string Nnyeah => Path.Combine (Configuration.SourceRoot, "tools", "nnyeah", "nnyeah", "bin", "Debug", "net6.0", "nnyeah.dll");
string Nnyeah => Path.Combine (Configuration.SourceRoot, "tools", "nnyeah", "nnyeah", "bin", "Debug", Configuration.DotNetTfm, "nnyeah.dll");
string NnyeahNupkg => Path.Combine (Configuration.SourceRoot, "tools", "nnyeah", "nupkg");
// TODO - This code, and passing xamarin-assembly/microsoft-assembly should be removed long term from nnyeah

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>