profile
viewpoint
Sam Harwell sharwell @microsoft San Diego, CA by way of Texas Turning coffee into code

microsoft/perfview 2383

PerfView is a CPU and memory performance-analysis tool

antlr/antlrcs 216

The C# port of ANTLR 3, StringTemplate 3, and StringTemplate 4

laurentkempe/GitDiffMargin 212

Git Diff Margin displays live Git changes of the currently edited file on Visual Studio margin and scroll bar. Supports Visual Studio 2012 through Visual Studio 2019

madskristensen/EditorConfigLanguage 103

A Visual Studio extension

pharring/EditorGuidelines 59

A Visual Studio extension that adds vertical column guides to the text editor

sharwell/antlr4cs 36

ANTLR 4 C# Target

rprouse/GitHubExtension 35

A visual studio extension for interacting with GitHub.

josetr/VsixTesting 16

VsixTesting allows you to easily test your Visual Studio Extensions.

issue commentdotnet/runtime

Dependency Injection of Open Generics via factory

I saw your project but didnt't tried it because it actually has same limitation of my implementation e.g. in my hacking attempt , in ConfigureServices of my 2nd host (built after the main was already running) I passed the main serviceprovider and its servicecollection and did this

// copies all the services registered in the forge, maintaining eventual singleton instances
// also copies over singleton instances already defined
foreach (ServiceDescriptor service in _registeredServices)
{
   if (service.ServiceType == typeof(IHostedService))
   {
      //prevent to start again an hosted service that's already running
      continue;
   }
   // open types failure, adding as service wull resolve to a new instance
   else if (service.ServiceType.IsGenericType)
   {
      services.Add(service);
   }
   else if (service.Lifetime == ServiceLifetime.Singleton)
   {
      services.AddSingleton(service.ServiceType, sp => _serviceProvider.GetServices(service.ServiceType).First(s => service.ImplementationType == null || s.GetType() == service.ImplementationType)); //resolve singletons from the main provider
   }
   else
   {
      services.Add(service);
   }
}

that gave me the false illusion it was working but (I was serving singleton by using the main _serviceProvider as wrapper), as you may guess, it generates duplicate IOptions for instance or other glitches if GetService on an open generic was accepting a factory it would work tho :/

wvpm

comment created time in 2 minutes

issue commentdotnet/runtime

Dependency Injection of Open Generics via factory

Hey @davidfowl I tried that approach, my problem is that I'm trying to run multiple Hosts using the same serviceprovider and actually the main serviceprovider is built before other hosts are configured so I can't add services to it. I tried to implement a kind of aggregator to simulate a child service provider but failed (a Iserviceprovider implementation that first tries to solve with the parent, then with the child serviceprovider, but I had too many problems and at the end it couldn't work if you try to resolve a service that have constructor parameters that has to be solved some on the parent container and some on the child container) I opened a discussion dotnet/aspnetcore#28228 to see what's the best way to achieve what I'm trying to achieve

I may be able to alter the design and delay the building of the main host in order to register everything in the same HostBuilder, exposing different APIs on different endpoints with swagger, eventually adding blazor server, etc... but I doubt it's feasible, if it is I'd like to know how

Have you looked at the Child containers provided by https://github.com/dazinator/Dazinator.Extensions.DependencyInjection - it has some tests - open generic registrations for singletons can result in duplicate singleton in the child container though (there are options for how you address this).

wvpm

comment created time in 10 minutes

Pull request review commentdotnet/runtime

Optimise GetCustomAttribute(s)

 internal static bool IsAttributeDefined(RuntimeModule decoratedModule, int decor                     {                         // Metadata is always written in little-endian format. Must account for this on                         // big-endian platforms.+                        int data = Unsafe.ReadUnaligned<int>((void*)blobStart);

Fixed

benaadams

comment created time in 13 minutes

issue commentdotnet/runtime

Dependency Injection of Open Generics via factory

Hey @davidfowl I tried that approach, my problem is that I'm trying to run multiple Hosts using the same serviceprovider the and actually the main serviceprovider is built before other hosts are configured so I can't add services to it. I tried to implement a kind of aggregator to simulate a child service provider but failed (a Iserviceprovider implementation that first tries to solve with the parent, then with the child serviceprovider, but I had too many problems and at the end it couldn't work if you try to resolve a service that have constructor parameters that has to be solved some on the parent container and some on the child container) I opened a discussion https://github.com/dotnet/aspnetcore/discussions/28228 to see what's the best way to achieve what I'm trying to achieve

I may be able to alter the design and delay the building of the main host in order to register everything in the same HostBuilder, exposing different APIs on different endpoints with swagger, eventually adding blazor server, etc... but I doubt it's feasible, if it is I'd like to know how

wvpm

comment created time in 16 minutes

Pull request review commentdotnet/runtime

Optimise GetCustomAttribute(s)

 internal static bool IsAttributeDefined(RuntimeModule decoratedModule, int decor             return false;         } -        private static object[] GetCustomAttributes(-            RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType? attributeFilterType)+        private static Attribute? GetCustomAttribute(+            RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType? attributeFilterType)         {-            RuntimeType.ListBuilder<object> attributes = default;-+            RuntimeType.ListBuilder<Attribute> attributes = default;             AddCustomAttributes(ref attributes, decoratedModule, decoratedMetadataToken, attributeFilterType, false, default); -            bool useObjectArray = attributeFilterType == null || attributeFilterType.IsValueType || attributeFilterType.ContainsGenericParameters;-            RuntimeType arrayType = useObjectArray ? (RuntimeType)typeof(object) : attributeFilterType!;+            if (attributes.Count == 0)+                return null;++            if (attributes.Count == 1)+                return attributes[0]; -            object[] result = CreateAttributeArrayHelper(arrayType, attributes.Count + pcaCount);-            for (int i = 0; i < attributes.Count; i++)-            {-                result[i] = attributes[i];-            }-            return result;+            throw new AmbiguousMatchException(SR.RFLCT_AmbigCust);         }          [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2065:UnrecognizedReflectionPattern",             Justification = "Linker guarantees presence of all the constructor parameters, property setters and fiels which are accessed by any " +                             "attribute instantiation which is present in the code linker has analyzed." +                             "As such the reflection usage in this method should never fail as those methods/fields should always be present.")]         private static void AddCustomAttributes(-            ref RuntimeType.ListBuilder<object> attributes,+            ref RuntimeType.ListBuilder<Attribute> attributes,             RuntimeModule decoratedModule, int decoratedMetadataToken,             RuntimeType? attributeFilterType, bool mustBeInheritable,-            // The derivedAttributes list must be passed by value so that it is not modified with the discovered attributes-            RuntimeType.ListBuilder<object> derivedAttributes)+            in RuntimeType.ListBuilder<Attribute> derivedAttributes)

Changed

benaadams

comment created time in 24 minutes

Pull request review commentgitextensions/gitextensions

FormResetAnotherBranch: display local tracking branches first

 private IGitRef[] GetLocalBranchesWithoutCurrent()             var currentBranch = Module.GetSelectedBranch();             var isDetachedHead = currentBranch == DetachedHeadParser.DetachedBranch; -            return Module.GetRefs(false)+            IGitRef[] refs = Module.GetRefs(false)                 .Where(r => r.IsHead && (isDetachedHead || r.LocalName != currentBranch))                 .ToArray();++            var remotes = _revision.Refs.Where(r => r.IsRemote).ToList();+            if (remotes.Count == 0)+            {+                return refs;+            }++            var refsOrdered = new List<IGitRef>();+            foreach (var remote in remotes)+            {+                IGitRef localBranch = refs.FirstOrDefault(r => r.MergeWith == remote.LocalName && r.TrackingRemote == remote.Remote);+                if (localBranch != null)+                {+                    refsOrdered.Add(localBranch);+                }+            }++            refsOrdered.AddRange(refs.Where(r => !refsOrdered.Contains(r)));+            return refsOrdered.ToArray();

refs[].IsRemote != remotes[].IsRemote ?

pmiossec

comment created time in 27 minutes

Pull request review commentgitextensions/gitextensions

FormResetAnotherBranch: display local tracking branches first

 private IGitRef[] GetLocalBranchesWithoutCurrent()             var currentBranch = Module.GetSelectedBranch();             var isDetachedHead = currentBranch == DetachedHeadParser.DetachedBranch; -            return Module.GetRefs(false)+            IGitRef[] refs = Module.GetRefs(false)                 .Where(r => r.IsHead && (isDetachedHead || r.LocalName != currentBranch))                 .ToArray();++            var remotes = _revision.Refs.Where(r => r.IsRemote).ToList();+            if (remotes.Count == 0)+            {+                return refs;+            }++            var refsOrdered = new List<IGitRef>();+            foreach (var remote in remotes)+            {+                IGitRef localBranch = refs.FirstOrDefault(r => r.MergeWith == remote.LocalName && r.TrackingRemote == remote.Remote);+                if (localBranch != null)+                {+                    refsOrdered.Add(localBranch);+                }+            }++            refsOrdered.AddRange(refs.Where(r => !refsOrdered.Contains(r)));+            return refsOrdered.ToArray();

I don't know what is the difference Module.GetRefs and _revision.Refs.

pmiossec

comment created time in 29 minutes

Pull request review commentgitextensions/gitextensions

FormResetAnotherBranch: display local tracking branches first

 private IGitRef[] GetLocalBranchesWithoutCurrent()             var currentBranch = Module.GetSelectedBranch();             var isDetachedHead = currentBranch == DetachedHeadParser.DetachedBranch; -            return Module.GetRefs(false)+            IGitRef[] refs = Module.GetRefs(false)                 .Where(r => r.IsHead && (isDetachedHead || r.LocalName != currentBranch))                 .ToArray();++            var remotes = _revision.Refs.Where(r => r.IsRemote).ToList();+            if (remotes.Count == 0)+            {+                return refs;+            }++            var refsOrdered = new List<IGitRef>();+            foreach (var remote in remotes)+            {+                IGitRef localBranch = refs.FirstOrDefault(r => r.MergeWith == remote.LocalName && r.TrackingRemote == remote.Remote);+                if (localBranch != null)+                {+                    refsOrdered.Add(localBranch);+                }+            }++            refsOrdered.AddRange(refs.Where(r => !refsOrdered.Contains(r)));+            return refsOrdered.ToArray();

image

pmiossec

comment created time in 33 minutes

pull request commentdotnet/runtime

Preserve UnmanagedCallersOnlyAttribute on mono, the runtime needs it, and it can be removed when using --used-attrs-only.

I think hardcoding in the linker was the old approach, and adding it to xml is the new one.

vargaz

comment created time in 35 minutes

pull request commentdotnet/runtime

Preserve UnmanagedCallersOnlyAttribute on mono, the runtime needs it, and it can be removed when using --used-attrs-only.

Is there a decoder ring for when these get added to CoreLib's XML and when do they get hardcoded into linker like https://github.com/mono/linker/pull/910?

(The --used-attrs-only option could be renamed to --break-the-app-subtly. When we finally put this option out of its misery and delete it, it would be preferable to have all of this special casing in the linker so that it disappears in one go.)

vargaz

comment created time in 42 minutes

Pull request review commentgitextensions/gitextensions

FormResetAnotherBranch: display local tracking branches first

 private IGitRef[] GetLocalBranchesWithoutCurrent()             var currentBranch = Module.GetSelectedBranch();             var isDetachedHead = currentBranch == DetachedHeadParser.DetachedBranch; -            return Module.GetRefs(false)+            IGitRef[] refs = Module.GetRefs(false)                 .Where(r => r.IsHead && (isDetachedHead || r.LocalName != currentBranch))                 .ToArray();++            var remotes = _revision.Refs.Where(r => r.IsRemote).ToList();+            if (remotes.Count == 0)+            {+                return refs;+            }++            var refsOrdered = new List<IGitRef>();+            foreach (var remote in remotes)+            {+                IGitRef localBranch = refs.FirstOrDefault(r => r.MergeWith == remote.LocalName && r.TrackingRemote == remote.Remote);+                if (localBranch != null)+                {+                    refsOrdered.Add(localBranch);+                }+            }++            refsOrdered.AddRange(refs.Where(r => !refsOrdered.Contains(r)));+            return refsOrdered.ToArray();

I ran this code, the order is the same.

private IGitRef[] GetLocalBranchesWithoutCurrent()
{
    var currentBranch = Module.GetSelectedBranch();
    var isDetachedHead = currentBranch == DetachedHeadParser.DetachedBranch;
    var remotes = _revision.Refs
        .Where(r => r.IsRemote);

    return Module.GetRefs(tags: false)
        .Where(r => r.IsHead)
        .Where(r => isDetachedHead || r.LocalName != currentBranch)
        .OrderByDescending(x => remotes.Any(y => x.IsTrackingRemote(y)))
        .ToArray();
}

Module.GetRefs returns a "List", which should guarantee ordering.

pmiossec

comment created time in 44 minutes

pull request commentdotnet/runtime

[Wasm] Update emscripten to 2.0.9

Tagging subscribers to this area: @directhex See info in area-owners.md if you want to be subscribed. <details> <summary>Issue Details</summary> <hr />

Aligns emscripten with mono/mono

<table> <tr> <th align="left">Author:</th> <td>jeromelaban</td> </tr> <tr> <th align="left">Assignees:</th> <td>-</td> </tr> <tr> <th align="left">Labels:</th> <td>

area-Infrastructure-mono

</td> </tr> <tr> <th align="left">Milestone:</th> <td>-</td> </tr> </table> </details>

jeromelaban

comment created time in an hour

PR opened dotnet/runtime

[Wasm] Update emscripten to 2.0.9

Aligns emscripten with mono/mono

+1 -1

0 comment

1 changed file

pr created time in an hour

Pull request review commentgitextensions/gitextensions

FormResetAnotherBranch: display local tracking branches first

 private IGitRef[] GetLocalBranchesWithoutCurrent()             var currentBranch = Module.GetSelectedBranch();             var isDetachedHead = currentBranch == DetachedHeadParser.DetachedBranch; -            return Module.GetRefs(false)+            IGitRef[] refs = Module.GetRefs(false)                 .Where(r => r.IsHead && (isDetachedHead || r.LocalName != currentBranch))                 .ToArray();++            var remotes = _revision.Refs.Where(r => r.IsRemote).ToList();+            if (remotes.Count == 0)+            {+                return refs;+            }++            var refsOrdered = new List<IGitRef>();+            foreach (var remote in remotes)+            {+                IGitRef localBranch = refs.FirstOrDefault(r => r.MergeWith == remote.LocalName && r.TrackingRemote == remote.Remote);+                if (localBranch != null)+                {+                    refsOrdered.Add(localBranch);+                }+            }++            refsOrdered.AddRange(refs.Where(r => !refsOrdered.Contains(r)));+            return refsOrdered.ToArray();

The .ThenBy(x => x.Name) is not possible because it will change the behavior that is to respect the order defined by the user in the settings.

image

And if we didn't put this clause, I don't know what is the default behavior. Will it keep the current order?

That's also the reason why I use the remotes collection instead of refs to iterate because I also wanted to keep that the order they appears. But most of the times their will be only one remote so maybe it's not that important....

pmiossec

comment created time in an hour

issue commentdotnet/runtime

HTTP2: Optimize huffman encoding static table initialization

My idea is to create ReadonlySpan<byte> containing source data from which the encoding table will be initialized.

private static ReadOnlySpan<byte> s_encodingTableData => new byte[257*5]
{
            0b11111111, 0b11000000, 0b00000000, 0b00000000, 13,
            0b11111111, 0b11111111, 0b10110000, 0b00000000, 23,
            ....
}

private static readonly (uint code, int bitLength)[] s_encodingTable = GenerateEncodingTable();

private static (uint code, int bitLength)[] GenerateEncodingTable()
{
    // TODO: build if from s_encodingTableData bytes by converting 4 bytes into 'uint code' and 5th into 'int bitLength'
}
rokonec

comment created time in an hour

issue openeddotnet/roslyn

Source Generators: all generated documents are empty when generator produces more than one document

When my source generator adds just one document using context.AddSource, Visual Studio can navigate to that generated document using Go to Definition on a user source file.

But when my source generator calls context.AddSource more than once, compilation succeeds but Go to Definition always opens an empty document (with the right filename).

VS version: 16.9 preview 3 (30727.24.main)

created time in an hour

pull request commentdotnet/runtime

IAsyncEnumerable support in Dataflow

I have rebased on master branch but the build still fails on a unit test failure that I managed to reproduce locally (by running it in loop until failure):

E:\git\runtime\artifacts\bin\System.Threading.Tasks.Dataflow.Tests\net6.0-Debug>E:\git\runtime\artifacts\bin\testhost\net6.0-windows-Debug-x86\dotnet exec --runtimeconfig System.Threading.Tasks.Dataflow.Tests.runtimeconfig.json --depsfile System.Threading.Tasks.Dataflow.Tests.deps.json xunit.console.dll System.Threading.Tasks.Dataflow.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing -method System.Threading.Tasks.Dataflow.Tests.DataflowBlockExtensionTests.ReceiveAllAsync*
  Discovering: System.Threading.Tasks.Dataflow.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Threading.Tasks.Dataflow.Tests (found 11 of 335 test cases)
  Starting:    System.Threading.Tasks.Dataflow.Tests (parallel test collections = on, max threads = 8)
    System.Threading.Tasks.Dataflow.Tests.DataflowBlockExtensionTests.ReceiveAllAsync_MultipleEnumerationsToEnd [FAIL]
      System.InvalidOperationException : An attempt was made to transition a task to a final state when it had already completed.
      Stack Trace:
        E:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncTaskMethodBuilderT.cs(443,0): at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetExistingTaskResult(Task`1 task, TResult result)
        E:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncIteratorMethodBuilder.cs(62,0): at System.Runtime.CompilerServices.AsyncIteratorMethodBuilder.Complete()
        E:\git\runtime\src\libraries\System.Threading.Tasks.Dataflow\src\Base\DataflowBlock.IAsyncEnumerable.cs(33,0): at System.Threading.Tasks.Dataflow.DataflowBlock.<ReceiveAllAsync>g__ReceiveAllAsyncCore|43_0[TOutput](IReceivableSourceBlock`1 source, CancellationToken cancellationToken)+MoveNext()
        E:\git\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncMethodBuilderCore.cs(42,0): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
           at System.Threading.Tasks.Dataflow.DataflowBlock.<ReceiveAllAsync>g__ReceiveAllAsyncCore|43_0[TOutput](IReceivableSourceBlock`1 source, CancellationToken cancellationToken)+System.Collections.Generic.IAsyncEnumerator<TOutput>.MoveNextAsync()
        E:\git\runtime\src\libraries\System.Threading.Tasks.Dataflow\tests\Dataflow\DataflowBlockExtensionTests.IAsyncEnumerable.cs(166,0): at System.Threading.Tasks.Dataflow.Tests.DataflowBlockExtensionTests.ReceiveAllAsync_MultipleEnumerationsToEnd()
        --- End of stack trace from previous location ---
  Finished:    System.Threading.Tasks.Dataflow.Tests
=== TEST EXECUTION SUMMARY ===
   System.Threading.Tasks.Dataflow.Tests  Total: 19, Errors: 0, Failed: 1, Skipped: 0, Time: 0,787s

Unfortunately, I do not understand what happens here. I would need some help.

manandre

comment created time in an hour

issue commentdotnet/runtime

HTTP2: Optimize huffman encoding static table initialization

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed. <details> <summary>Issue Details</summary> <hr />

Currently huffman encoding static table is currently compiled into ~5,5K IL bytes which is JITed into ~9.5K of ASM code.

Sharplab prove

It might be beneficial to somehow optimize above.

<table> <tr> <th align="left">Author:</th> <td>rokonec</td> </tr> <tr> <th align="left">Assignees:</th> <td>-</td> </tr> <tr> <th align="left">Labels:</th> <td>

area-System.Net.Http, untriaged

</td> </tr> <tr> <th align="left">Milestone:</th> <td>-</td> </tr> </table> </details>

rokonec

comment created time in an hour

issue openeddotnet/runtime

HTTP2: Optimize huffman encoding static table initialization

Currently huffman encoding static table is currently compiled into ~5,5K IL bytes which is JITed into ~9.5K of ASM code.

Sharplab prove

It might be beneficial to somehow optimize above.

created time in an hour

issue openedantlr/antlr4

possibly a typo on https://github.com/antlr/antlr4/blob/master/doc/getting-started.md

I think .jar.jar should be replaced with .jar

$ export CLASSPATH=".:/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH"

It's also a good idea to put this in your .bash_profile or whatever your startup script is.

Create aliases for the ANTLR Tool, and TestRig.

$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH" org.antlr.v4.Tool' $ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'

created time in an hour

issue commentdotnet/aspnetcore

[Performance] HTTP APIs in MVC

I've started to make some changes in this area and I took a profile of the MvcJson scenario under https://github.com/aspnet/Benchmarks/blob/98cbf5bb8b39bab3c2646b752a91a18d2ccb4278/src/BenchmarksApps/Mvc/benchmarks.mvcjson.yml and after some trimming here is a baseline CPU profile:

image

This application hasn't cleared logging providers so some of that overhead shows up here but it's currently trimmed out of this profile's view. I've highlighted some of the top level areas to look at that are directly in MVC taking up a some percentage of time (> 1% exclusive time).

sebastienros

comment created time in an hour

issue openeddotnet/aspnetcore

Blazor webassembly azure ad authentication issue after migration to .net5

Blazor webassembly azure ad authentication issue after migration to .net5

Error: AADSTS28000: Provided value for the input parameter scope is not valid because it contains more than one resource. Scope https://graph.microsoft.com/User.Read api://861be009-5e73-4c6c-a095-b6e193522222/API. Access openid profile is not valid.

Scope Code(web assembly):

builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
    options.ProviderOptions.DefaultAccessTokenScopes.Add("https://graph.microsoft.com/User.Read");
    options.ProviderOptions.DefaultAccessTokenScopes.Add("api://861be009-5e73-4c6c-a095-b6e193522222/API.Access");

created time in an hour

issue openeddotnet/sdk

dotnet new locks after execution

I tried to create a new program through dotnet new command, it will lock after restore succeeded message and I have to exit by pressing ctrl + c. Also, I used Command-Masure to measure the execution time it takes ~1min to be released. I'm experiencing this since .NET Core 3.1, it's constant in the early versions.

PS C:\dotnet\DotnetNewLock> Measure-Command { dotnet new console | Out-Host }
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\Users\sohei\code\dotnet\DotnetNewLock\DotnetNewLock.csproj...
  Determining projects to restore...
  Restored C:\Users\sohei\code\dotnet\DotnetNewLock\DotnetNewLock.csproj (in 71 ms).
Restore succeeded.

// it locks here


Days              : 0
Hours             : 0
Minutes           : 1
Seconds           : 42
Milliseconds      : 429
Ticks             : 1024295068
TotalDays         : 0.00118552669907407
TotalHours        : 0.0284526407777778
TotalMinutes      : 1.70715844666667
TotalSeconds      : 102.4295068
TotalMilliseconds : 102429.5068

\cc @dsplaisted @wli3 @sfoslund

created time in an hour

issue commentdotnet/roslyn-analyzers

Check Web APIs returning ActionResult with status code 2xx

It would go here btw https://github.com/dotnet/aspnetcore/tree/master/src/Analyzers/Analyzers/src

sshanzel

comment created time in an hour

issue commentdotnet/runtime

System.Reflection.MetadataLoadContext doesn't support function pointer types

Yes it will be required for https://github.com/dotnet/runtime/issues/44636

vargaz

comment created time in 2 hours

issue commentdotnet/roslyn-analyzers

Helper tool for nullable annotations

Why then did .Net team create this dotnet/runtime#2339 and now also dotnet/runtime#41720?

Probably the runtime team did the annotation based on what types/assemblies they think are used a lot by developers. Types that aren't frequently used or legacy were given a much lower priority to annotate. But that's just a guess of what may have happened.

(Note that the runtime provide public APIs that're used by other developers, so annotating makes a different to consumers, so priority based on API popularity sounds very reasonable. This might not be the same for PowerShell if it doesn't provide public APIs to be used by other developers).

iSazonov

comment created time in 2 hours

issue commentdotnet/runtime

RyuJIT: Partial Inline of CORINFO_HELP_ISINSTANCEOFCLASS

Numbers for a quite heavy Avalonia UI app:

isNull=43935 sameType=239801 sameParentType=340210 other=340210 
EgorBo

comment created time in 2 hours

Pull request review commentdotnet/runtime

Design document for Objective-C interop

+# Objective-C interoperability++This design document describes a singular .NET Platform support scenario for an Objective-C runtime. This design is heavily influenced by existing [Xamarin-macios][xamarin_repo] support which is built on top of Mono's [Embedding API](https://www.mono-project.com/docs/advanced/embedding/).++## Objective-C concepts++There are concepts in Objective-C that require attention for interoperability.++**Message dispatch** <a name="message_disp"></a>++Method dispatch in Objective-C is typically done through message passing. A suite of functions make up the message passing system.++- [`objc_msgSend`](https://developer.apple.com/documentation/objectivec/1456712-objc_msgsend) - Canonical message passing.+- [`objc_msgsend_fpret`](https://developer.apple.com/documentation/objectivec/1456697-objc_msgsend_fpret) - Message returns a floating point value.+- [`objc_msgSend_stret`](https://developer.apple.com/documentation/objectivec/1456730-objc_msgsend_stret) - Message returns a structure.+- [`objc_msgSendSuper`](https://developer.apple.com/documentation/objectivec/1456716-objc_msgsendsuper) - Send message to the super class.+- [`objc_msgSendSuper_stret`](https://developer.apple.com/documentation/objectivec/1456722-objc_msgsendsuper_stret) - Send message that returns a structure to the super class.++Each of these functions are designed to look up the target method on the object ([`id`](https://developer.apple.com/documentation/objectivec/id)) based on the supplied selector ([`SEL`](https://developer.apple.com/documentation/objectivec/sel)) and then `jmp` to that method ([`IMP`](https://developer.apple.com/documentation/objectivec/objective-c_runtime/imp)). Note that this is a `jmp`, not a `call`. From the perspective of the caller the return is from the target method not the message dispatch function. Looking up the above functions, one will note each are defined with a `void(*)(void)` signature. During the compilation of Objective-C code, the compiler will compute the appropriate function signature, cast the message passing function, and make the call. All Objective-C methods have two implied arguments - the object (i.e. `id`) and the message selector (`SEL`). This means the following Objective-C statement:++```objective-c+int b = [obj doubleNumber: a];+```++Will be converted by the compiler to the C style signature of:++```C+// The SEL, "doubleNumberSel", is computed at compile time.+// A SEL can also be constructed at run time.+int b = ((int(*)(id,SEL,int))&objc_msgSend)(obj, doubleNumberSel, a);+```++The Objective-C runtime adheres to the [`cdecl`](https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl) calling convention for all function calls. It should be noted that variadic arguments are supported in Objective-C.++**Exceptions**++The Objective-C implementation of exceptions is able to be correctly simulated through a series of well defined C functions provided by the Objective-C runtime. Details on this ABI aren't discussed here, but can be observed in various hand-written assembly code (e.g. [x86_64](https://github.com/xamarin/xamarin-macios/blob/main/runtime/trampolines-x86_64-objc_msgSend-post.inc)) in the Xamarin-macios code base.++**Blocks**++An Objective-C Block is conceptually a closure. The [Block ABI][blocks_abi] described by the clang compiler is used to inform interoperability with the .NET Platform. The Objective-C signature of a Block has an implied first argument for the Block itself. For example, a Block that takes an integer and returns an integer would have the follow C function signature: `int (*)(id, int)`.++## Interaction between Objective-C and .NET types++Creating an acceptable interaction model between Objective-C and .NET type instances hinges on addressing several issues.++**Identity**++The mapping between an Objective-C [`id`](https://developer.apple.com/documentation/objectivec/id) and a .NET `object` is of the upmost importance. Aside from issues around inefficient memory usage, the ability to know a .NET `object`'s true self is relied upon in many important scenarios (e.g. Key in a `Dictionary<K,V>`).++Ensuring a robust mapping between these concepts can be handled more efficiently within a runtime implementation. This necessitates the ability for the consumer to register a pair (`id` and `object`) and whenever asked for one, the other can be returned.++**Lifetime**++Objective-C lifetime semantics are handled through [manual or automatic reference counting](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html). Reconciling this with the .NET Platform's Garbage Collector will require different solutions for each .NET runtime implementation.++_Note_: In the following illustrations, a strong reference is depicted as a solid line (`===`) and a weak reference is depicted as a dashed line (`= = =`).++When a .NET object enters an Objective-C environment, the Objective-C proxy is subject to reference counting and ensuring it extends the lifetime of the managed object it wraps. This can be accomplished in CoreCLR through use of the internal `HNDTYPE_REFCOUNTED` GC handle type. This handle, coupled with a reference count, can be used to transition a GC handle between a weak and strong reference.++Creating an Objective-C proxy will also require overriding the built-in [`retain`](https://developer.apple.com/documentation/objectivec/1418956-nsobject/1571946-retain) and [`release`](https://developer.apple.com/documentation/objectivec/1418956-nsobject/1571957-release) methods provided by the Objective-C runtime.

This overriding would only occur if the most derived type is managed (i.e. defined in C#). All types originally defined in Objective-C would have their originally defined methods. This seems to be acceptable given the documentation on retain and release that indicate one can implement reference counting however desired.

You would implement this method only if you were defining your own reference-counting scheme. Such implementations must return self and should not invoke the inherited method by sending a retain message to super.

Given the above statement in the documentation, this model aligns with your statement about what one can expect but also implies the ownership of calling dealloc is left to the implementor of the retain and release since messages are not send to super.

This appears to be identical to the COM implementation of AddRef/Release. One facet that isn't in COM is support for an explicit reference count query (i.e. retainCount), but that would be trivial to also override. However the documentation for retainCount also states:

Do not use this method.

So I am less concerned about needing to support that method.

AaronRobinsonMSFT

comment created time in 2 hours

Pull request review commentdotnet/roslyn-analyzers

CA2119: Fix false negative with extended interface

 End Class ");         } +        [Fact, WorkItem(4406, "https://github.com/dotnet/roslyn-analyzers/issues/4406")]+        public async Task CA2119_ExtendedInterface()+        {+            await VerifyCS.VerifyAnalyzerAsync(@"+namespace FxCopRule

nit: No need for the namespace declaration.

Evangelink

comment created time in 2 hours

pull request commentdotnet/runtime

Design document for Objective-C interop

I'm assuming this has a generic .NET 6 timeline unless you say otherwise?

Yes. This is for .NET 6. I don't think, naively, this would represent a large time investment from the Diagnostics team. I am assuming it would be similar to the ComWrappers support - https://github.com/dotnet/runtime/pull/42942 https://github.com/dotnet/runtime/pull/43164.

AaronRobinsonMSFT

comment created time in 2 hours

more