Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:36
    dotnet-maestro[bot] commented #42843
  • 14:31
    dotnet-maestro[bot] commented #42843
  • 14:26
    dotnet-maestro[bot] commented #42843
  • 14:21
    dotnet-maestro[bot] commented #42843
  • 14:20
    TehWardy commented #42562
  • 14:16
    dotnet-maestro[bot] commented #42843
  • 14:11
    dotnet-maestro[bot] commented #42843
  • 14:06
    dotnet-maestro[bot] commented #42843
  • 14:01
    dotnet-maestro[bot] commented #42843
  • 13:55
    dotnet-maestro[bot] commented #42843
  • 13:50
    dotnet-maestro[bot] commented #42843
  • 13:48
    HobbsCode edited #42880
  • 13:45
    dotnet-maestro[bot] commented #42843
  • 13:40
    HobbsCode commented #42880
  • 13:40
    dotnet-maestro[bot] commented #42843
  • 13:40
    YairHalberstadt commented #42880
  • 13:35
    dotnet-maestro[bot] commented #42843
  • 13:32
    HobbsCode commented #42880
  • 13:30
    dotnet-maestro[bot] commented #42843
  • 13:25
    dotnet-maestro[bot] commented #42843
Joseph Musser
@jnm2
Bookmarking
Robin Sue
@Suchiman
although i wonder if that is only for switch or if it includes things like object initializer, the PR claims to close dotnet/roslyn#42579 which says it should support object initializer
Joseph Musser
@jnm2
I'd go by the PR title
Robin Sue
@Suchiman
Joseph Musser
@jnm2
And I skimmed half of it and only noticed switch expression stuff
CyrusNajmabadi
@CyrusNajmabadi
lollllllllll
Robin Sue
@Suchiman
@CyrusNajmabadi so... how bad was that email? :laughing:
CyrusNajmabadi
@CyrusNajmabadi
it was amazing
i wish i had printed it out and framed it
Yair Halberstadt
@YairHalberstadt
Now you're just teasing us...
Joseph Musser
@jnm2
or mourning its loss
Joseph Musser
@jnm2
@jcouv For the type symbol pointed to by ModuleInitializerAttribute, would you recommend including the generated stub method in GetMembers or no?
(https://github.com/dotnet/csharplang/issues/2608#issuecomment-525902708)
Joseph Musser
@jnm2
I'm going to guess no for now. In that case, I still have to figure out where to persist the SynthesizedUserModuleInitializerTriggerMethod method symbol so that I can gen the code to call it from SynthesizedRootModuleTypeStaticConstructor.GenerateMethodBody.
Not sure I want to add an additional field to SourceNamedTypeSymbol just in case it's the one indicated by a ModuleInitializerAttribute.
SourceModuleSymbol seems like the most natural storage location for the SynthesizedUserModuleInitializerTriggerMethod then?
Joseph Musser
@jnm2
other options would be CSharpRootModuleType and PEModuleBuilder too.
When you're not super familiar with something, it can seem like there are dozens of equally valid combinations of ways to do each thing.
CyrusNajmabadi
@CyrusNajmabadi
the same applies even when familiar :)
Joseph Musser
@jnm2
Sometimes. I can't tell if this is one of those times.
For example, the part about including in GetMembers seems like it will have a definite answer from someone.
(given the outcome of my rejected PR that started including event backing fields in GetMembers)
Joseph Musser
@jnm2
Ooh, thought of something that means I'm changing one file instead of three. Guess I'll do that.
Joseph Musser
@jnm2
I have the success case working! Compile output passes the tests! 🎉
Joseph Musser
@jnm2
Tomorrow I'll add more tests and implement diagnostics, then open a draft PR to find out everything that's wrong with my guesses.
https://github.com/dotnet/roslyn/compare/master...jnm2:module_initializer
Joseph Musser
@jnm2
Except Julien might be telling me to wait
Ringo De Smet
@ringods
What is the state of Roslyn on .NET Core for Mac/Linux? Does anything still requires a full .NET on Windows?
Yair Halberstadt
@YairHalberstadt
Nope
Joseph Musser
@jnm2
I believe all of Roslyn was compiled for .NET Standard in order to ship it in the .NET Core 1.0 SDK.
Ringo De Smet
@ringods
But I guess I could still require a full .NET when I point my Roslyn based analysis tool to a Windows .NET project?
Joseph Musser
@jnm2
You would use MSBuildWorkspace and MSBuildLocator for that, and yes, some (not all) .NET Framework projects require your analyzing process to run .NET Framework and use the .NET Framework build of MSBuild.
The only such project I can think of right now is Roslyn.sln itself. That fails to load unless your tool is running in .NET Framework.
Ringo De Smet
@ringods
Context: we are building a tool that we want to run over the .NET Git project repos of our customers. Since we can’t reproduce the build environment of our customer 100% (e.g. private nuget deps, different .NET runtimes), can we build our Roslyn based build tool that it can execute source analysis tasks without requiring a correct compilation/build?
Yair Halberstadt
@YairHalberstadt
In general that will be very difficult if you don't have access to all the same assemblies
Joseph Musser
@jnm2
It sounds difficult. MSBuildWorkspace does not do NuGet restores, so you'd be missing all dependent assemblies and all NuGet package .targets and .props.
Worst case (like Roslyn.sln, where all projects show up with 0 documents unless you run on .NET Framework), you can definitely build the compilations yourself using https://buildalyzer.netlify.com/ to read the projects. You can download what you can from nuget.org and reference it in the compilations to avoid getting error symbols for missing types. You can still analyze the syntax even without referencing any real assemblies too.
This is something I've thought about doing, too. :)
Yair Halberstadt
@YairHalberstadt

Convert to switch statement refactoring is brilliant:

                if (result is true || result is "" || result is null)
                {
                    successes.Add(method.Name);
                }
                else if (result is false)
                {
                    failures.Add((method.Name, "failed"));
                }
                else if (result is string message)
                {
                    failures.Add((method.Name, message));
                }
                else
                {
                    Release.Fail("This location is thought to be unreachable");
                }

To

                switch (result)
                {
                    case true:
                    case "":
                    case null:
                        successes.Add(method.Name);
                        break;
                    case false:
                        failures.Add((method.Name, "failed"));
                        break;
                    case string message:
                        failures.Add((method.Name, message));
                        break;
                    default:
                        Release.Fail("This location is thought to be unreachable");
                        break;
                }
CyrusNajmabadi
@CyrusNajmabadi
@alrz
we wnat to update it for the new pattern work
i.e. case true or "" or null
Yair Halberstadt
@YairHalberstadt
Yep
Alireza Habibi
@alrz
already in my backlog
pattern combinators enable lots of new stuff

case true or "" or null

I'd be wary to do that for switch statements since multi-case is already clear? switch expressions have to use or-patterns though

Yair Halberstadt
@YairHalberstadt
In this case I would prefer or as they are short and it saves two lines
If they were larger patterns though I would prefer case to break them up.
Alireza Habibi
@alrz
yeah probably good idea to gate on the length
also there's some combinations that need to use or-patterns anyways,
e.g. if we have a case guard on a set of patterns case p1 or p2 when c1: case p3 or p4 when c2: that's not possible in C# 8.0 unless you duplicate case guards
CyrusNajmabadi
@CyrusNajmabadi
I'd be wary to do that for switch statements since multi-case is already clear? switch expressions have to use or-patterns though
we can also have a refactoring directly for this
i.e. "convert multiple cases into single"
Krzysztof Janik
@kjanik14_gitlab
Hi, is there a way to get System.Type from Microsoft.CodeAnalysis.ISymbol object? (it's enough if I could have name of this type)
Joseph Musser
@jnm2
@kjanik14_gitlab You can't get a System.Type; that would mean either that the types were loaded for execution into the compiler process (bad) or that someone reimplemented the abstract System.Type model backed by ISymbol which doesn't seem like a useful thing to do since ISymbol is richer. I don't know offhand how to obtain the full metadata name besides iterating over .ContainingSymbol and collecting ISymbol.MetadataName values and joining them with periods. @CyrusNajmabadi might?
What I do know offhand is that you can use the GetTypeByMetadataName(fullyQualifiedTypeName) method on Compilation or IAssemblySymbol. Maybe if you're comparing things based on a full name string, you can switch to comparing things using an ITypeSymbol.