Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 22:32

    msftbot[bot] on master-vs-deps

    Remove unnecessary parens when … Fix tests Add StackOverflow InteractiveWi… and 3 more (compare)

  • 22:32

    msftbot[bot] on master-to-master-vs-deps

    (compare)

  • 22:32
    msftbot[bot] milestoned #49808
  • 22:32
    msftbot[bot] closed #49808
  • 21:03

    dotnet-bot on release

    (compare)

  • 21:03

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

  • 21:02

    dotnet-bot on release

    (compare)

Leandro T. C. Melo
@ltcmelo
sorry, but what do you mean by workspace layer?
CyrusNajmabadi
@CyrusNajmabadi
i.e. var g = SyntaxGenerator.GetGenerator(myDocument)
roslyn is built of layers. lowest layer is just the compiler layer. this is the low level analysis/generation apis.
higher layer is the workspace layer. this is what exposes a full 'Solution' model that stiches everything together
has higher level ops (like 'rename') and whatnot
its what powers the IDE
Leandro T. C. Melo
@ltcmelo
alright, you mean Workspace
I wasn’t sure
CyrusNajmabadi
@CyrusNajmabadi
there are even higher layers than that. but hte workspace layer is what has the SyntaxGenerator code
Leandro T. C. Melo
@ltcmelo
but how would that different from standard SyntaxFactory methods?
CyrusNajmabadi
@CyrusNajmabadi
so, note how i had:
g.CastExpression(typeSymbol, g.DefaultExpression(typeSymbol))
that's passing in a symbol, not a node
Leandro T. C. Melo
@ltcmelo
got it
CyrusNajmabadi
@CyrusNajmabadi
here, it would generate the proper syntax to represent hte higher level concept of casting a node to a type
and it would be appropriately annotated so that if you passed it through teh Simplfiier api it would shorten and whatnot to the minimal style
Leandro T. C. Melo
@ltcmelo
still, I don’t see why you need a Workspace for ~SyntaxGenerator.CastExpression…?~
hum… is this because of the Document, which i used in GetGenerator?
CyrusNajmabadi
@CyrusNajmabadi
yes
Leandro T. C. Melo
@ltcmelo
:+1:
thanks @CyrusNajmabadi
CyrusNajmabadi
@CyrusNajmabadi
it's because Workspace figures out how to generate for different languages
and it utilizes services that are MEF discovered.
CyrusNajmabadi
@CyrusNajmabadi
Can you clarify your question @Youssef1313 ?
Here's an example:
class C { public C(); }
Joe4evr
@Joe4evr
if only that was legal to write manually 🙃
Simon Ziegler
@simonziegler
Hi, I have an INamespaceOrTypeSymbol representing an abstract generic record (C# 9). I need to determine whether this is generic but find that the IsGenericType property of INamespaceOrTypeSymbol is inaccessible. Any thoughts?
Johan Larsson
@JohanLarsson
if (x is INamedTypeSymbol { IsGenericType: true })
{
    ...
}
pseudo unless it happens to compile
Simon Ziegler
@simonziegler
Oh. I'm using Source Generation, which itself is .netstandard 2.1 and C# 7.3. So that code pattern is unavailable sadly. A great pattern that I didn't know existed and I'll remember it for future use! Unfortunately I'm still stuck...
So to be clear, my generator is on C# 7.3, but it's generating C# 9
Johan Larsson
@JohanLarsson
for old lang versions do if ((x as INamedTypeSymbol)?.IsGenericType == true)
Simon Ziegler
@simonziegler
Bingo! Thanks!
stefanloerwald
@stefanloerwald
Why don't you bring the SG to <LangVersion>latest</LangVersion> as well?
Simon Ziegler
@simonziegler
Didn't think of that - you may recall I'm not so good with MSBuild related things...
Simon Ziegler
@simonziegler
@JohanLarsson the cast to INamedTypeSymbol worked. Thanks!
Antony Male
@canton7
Officially C# 9 is only supported on .NET 5, but there's nothing stopping you from targeting a later lang version in an earlier runtime: it's just if you try and use language feature which rely on the newer runtime you'll see errors, though you can often polyfill to get around them. I'm using C# 9 in a source generator just fine
Simon Ziegler
@simonziegler
Cool.
Joe4evr
@Joe4evr
@Youssef1313 now that I think about it, I believe certain COM scenarios warrant having a managed type with an extern constructor, in which case it'll be:
class C { public extern C(); }
and then the SemicolonToken will exist
Leandro T. C. Melo
@ltcmelo
are the strings that represent operator names (e.g., op_Inequality) present in the API as constants, anywhere?
can’t seem to find… (guess I’d need to constify myself)
Antony Male
@canton7
@ltcmelo WellKnownMemberNames.InequalityOperatorName? From a brief search on github
Leandro T. C. Melo
@ltcmelo
great! thanks, @canton7
Martin Vseticka
@MartyIX
hm, this would be great to have dotnet/runtime#29631
Joseph Musser
@jnm2
Is there an IDE or CA rule that could be configured to warn when a variable is assigned a value that is never used?
Joseph Musser
@jnm2
Okay, so IDE0059 bails in methods that have lambda expressions
CyrusNajmabadi
@CyrusNajmabadi
@jnm2 that surprises me. Might want to file an issue on that