## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• 21:47
runfoapp[bot] edited #57982
• 21:47
runfoapp[bot] edited #57980
• 21:46
runfoapp[bot] edited #57837
• 21:46
runfoapp[bot] edited #57797
• 21:46
runfoapp[bot] edited #57722
• 21:46
runfoapp[bot] edited #57423
• 21:46
runfoapp[bot] edited #57565
• 21:46
runfoapp[bot] edited #57551
• 21:46
runfoapp[bot] edited #56625
• 21:45
runfoapp[bot] edited #49400
• 21:45
runfoapp[bot] edited #49026
• 21:45
runfoapp[bot] edited #46414
• 21:45
runfoapp[bot] edited #53392
• 21:45
runfoapp[bot] edited #53391
• 21:31
runfoapp[bot] edited #57982
• 21:31
runfoapp[bot] edited #57980
• 21:31
runfoapp[bot] edited #57837
• 21:31
runfoapp[bot] edited #57797
• 21:31
runfoapp[bot] edited #57722
• 21:31
runfoapp[bot] edited #57423
Hugh Gleaves
@Korporal
(19,34): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I already add a bunch of references including C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.11\System.Private.CoreLib.dll and C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.11\netstandard.dll
Hugh Gleaves
@Korporal
ok its working
I basically do dthis
                var colRefLocation = AppDomain.CurrentDomain.GetAssemblies().Single(a => a.GetName().Name == "System.Collections").Location;
var stdRefLocation = AppDomain.CurrentDomain.GetAssemblies().Single(a => a.GetName().Name == "netstandard").Location;
var sysrLocation = AppDomain.CurrentDomain.GetAssemblies().Single(a => a.GetName().Name == "System.Runtime").Location;
Antony Male
@canton7
@Korporal Using Roslyn, presumably? Look at https://github.com/jaredpar/basic-reference-assemblies for the correct set of reference assemblies for a given target
jamespgatt
@jamespgatt

Hi there, I have a solution that contains 3 projects:

• a library (netstandard 2.0) that is using ISourceGenerator
• a WebAPI project (net5.0) that has some controllers with actions
• a Test (net5.0 with xunit) that has unit tests

Basically the flow I want to achieve is that the SourceGenerator class will analyse all action methods and generate a sample unit test [fact] for each action method.
However what I am realising is that SyntaxTrees only accesses one executing assembly at a time - i.e. if the source generator is being executed on the Test proj (even with WebAPI proj referenced), syntaxtrees for WebAPI are not accessible.

Is there a way around this?

Nope
That's fundamental to analyzer and sg design.
They operate on one compilation at a time.
This models how compilation actually works. When you are compiling a project X, it's dependencies are passed to it as metadata references, not source code.
@jamespgatt you shouldn't need syntax trees for what you're doing - just MethodSymbols
jamespgatt
@jamespgatt
Thanks will check it out
suresh palepu
@satyasuresh:matrix.org
[m]

Hi All

I am trying to disable the "SA1101" stylecop warning in .net core

added below line the .ediitorconfig, but still showing the warining

dotnet_diagnostic.SA1101.severity = none

a

Martin Vseticka
@MartyIX

Guys, I have NLog as dependency in my analyzer: https://github.com/dotnet/roslyn/discussions/56643#discussioncomment-1378880.

Now I wonder about this line <PackageReference Include="NLog" Version="4.7.5" PrivateAssets="all" GeneratePathProperty="true" /> in my analyzer project. Is it recommended to add PrivateAssets="all" or not? My fear is that NLog dependency ends up in CUSTOMER's project by transitivity rule. Is that reasonable fear or is it a nonsense?

Why don't you test. Setup a local folder as a nuget source, generate a nuget package and copy to that folder, reference the analayzer froma seperate project, and see what happens.
Joe4evr
@Joe4evr
:arrow_up:
As an aside, I wish that roslyn passed in a logger to analyzers/source generators
Joe4evr
@Joe4evr
word
Antony Male
@canton7
There was a request for that
Martin Vseticka
@MartyIX
ok, so it seems to me that the reference is not propagated to the customer's project.
However, I have just found that other 3rd party dependencies leak into the customer's project thanks to my nuget packages :facepalm:
Benjamin
@benjamin-asdf
Hi, I'd like to get a recursive call graph of a method. Like all methods that it uses (down into other assemblies)
Elan Hasson
@elanhasson:matrix.org
[m]
Why are source generators only additive?
Joe4evr
@Joe4evr
because it's exponentially more complicated to spec order of execution when replacement is involved
Leandro T. C. Melo
@ltcmelo
hi...
I have an unexpected situation: an object propSym (of type IPropertySymbol) whose Name is null, ie, propSym.Name == null holds
I don't have any context about the source in question because this error is coming from a (customer) log
my understanding is that propSym.Name could return an empty string but not null
I'm wondering whether this could happen anyhow... does anyone have a hint?
Bernd Baumanns
@bernd5
hey
I'd like to analyze the dataflow of a ConstructorInitializerSyntax
Unfortenately it is not an expression nor a statement
it has the same characteristics as a statement - but it does not inherit from it (because it is only valid at a single position...)
For now I "solved" it by creating a dummy method with an ObjectCreationExpressionSyntax of the base / delegated constructor and analyzed that
the result is fine - but I need to map the new symbols back to the old ones
Could we allow AnalyzeDataFlow not only for statements and expression's but also for ConstructorInitializer expressions?
Bernd Baumanns
@bernd5
Or do you have another good idea?
Bernd Baumanns
@bernd5
@ltcmelo it could be an indexer
indexers do not have a name ...
that they are mapped to IPropertySymbol is a bit strange, but ...
I think in VB they can have names - in csharp not
Leandro T. C. Melo
@ltcmelo
@bernd5 thanks but an indexer does have a valid name
BTW, about your question @bernd5 : you could rewrite the initializer into the constructor body (prior to analysis)
I do similar things in this library https://github.com/ShiftLeftSecurity/SharpSyntaxRewriter
Bernd Baumanns
@bernd5
That is what I did - but the rewrite the symbols are different (they belong to the rewritten code ...)
@ltcmelo what is the name of an indexer?
Is "this" returned?
I would think null would be okay, too
the best is maybe to extend roslyn... I create a PR
Leandro T. C. Melo
@ltcmelo

the rewrite the symbols are different (they belong to the rewritten code ...)

correct, so what I do is to recompute the semantic model, then you get valid symbols and a correspondence

Bernd Baumanns
@bernd5
Bernd Baumanns
@bernd5
Bernd Baumanns
@bernd5
at least the GC is not deterministic