Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 02:03
    tmat commented #65627
  • 02:01
    cston commented #65651
  • 02:01
    cston commented #65651
  • 01:36
    CyrusNajmabadi synchronize #65500
  • 01:26
    msftbot[bot] milestoned #65508
  • 01:26
    msftbot[bot] milestoned #65508
  • 01:26

    CyrusNajmabadi on main

    Improve consistency in our pars… (compare)

  • 01:26
    CyrusNajmabadi closed #65508
  • 01:24
    msftbot[bot] milestoned #65653
  • 01:24
    msftbot[bot] milestoned #65653
  • 01:24

    dotnet-bot on main-vs-deps

    Out arguments do not contribute… Fix null ref in persistence ser… revert and 4 more (compare)

  • 01:24
    dotnet-bot closed #65653
  • 01:23
    CyrusNajmabadi synchronize #65655
  • 01:21
    CyrusNajmabadi auto_merge_enabled #65654
  • 01:21
    CyrusNajmabadi synchronize #65654
  • 01:18
    CyrusNajmabadi review_requested #65655
  • 01:09
    CyrusNajmabadi synchronize #65655
  • 01:07
    dotnet-issue-labeler[bot] labeled #65656
  • 01:07
    sandyarmstrong review_requested #65656
  • 01:07
    sandyarmstrong review_requested #65656
Mohammad Hamdy Ghanem
@VBAndCs
Thanks. This was helpful :). At least we discovered something new in VB.NET :).
Michael Fry
@nth-commit
Does anyone know of any guides which describe the relationship/non-relationship between the semantic model and System.Reflection? It's something I bump into all the time and haven't quite taken the time to understand. I am super familiar with navigating around System.Reflection and doing dynamic type stuff. Not so familiar with navigating around the semantic model (e.g. Compilation, ITypeSymbol). It would be nice if there was something I could read through which would help relate my familiarity with the former to the latter.
CyrusNajmabadi
@CyrusNajmabadi
There's no API relation. In that there no strong way to tie the entities from one to another.
However, there is a weak relation. System.Reflection allows for an API for a few purposes: introspecting metadata and querying against live values at runtime.
The Roslyn symbol model rejects reflects the static semantics of code at compile time.
There are many similar ideas in both.
For example PropertyInfo in reflection, and IPropertySymbol in Roslyn.
Roslyn has no runtime querying concept though*. It's all (mostly) about the information at compile time.
Michael Fry
@nth-commit

Thanks :)

Yeah I understand. Although a large portion of System.Reflection is to do with statically available info (obviously I don't expect roslyn to be able to give me runtime values if there isn't a program running, so there's no representation of CreateInstance, SetValue, GetValue etc.).

For example PropertyInfo in reflection, and IPropertySymbol in Roslyn

This is the stuff I want to hear about :D. I just want to know if these kinds of relationships are documented somewhere - and is it a value that the roslyn team hold or is any symmetry between the APIs incidental?

CyrusNajmabadi
@CyrusNajmabadi
Both? :-)
Both the language and the bcl need to represent things from metadata. And metadata in c# is produced from source. So there's are just common ways of representing those entities.
timiil
@timiil
Is there any opensource solution that use Roslyn to 'obfuscation' or 'protect' .NET PE ?
Bernd Baumanns
@bernd5
roslyn only emits IL - but it doesn't modify it
Yair Halberstadt
@YairHalberstadt

IsNullableTypeOrTypeParameter (https://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp/Symbols/TypeSymbolExtensions.cs,113) checks if a constraint type is a nullable type.

But how is this ever possible since structs can't be constraints? Is it only if the constraint is defined in a different language?

Mohammad Hamdy Ghanem
@VBAndCs
Languages are getting more complex (esp C#). It would be helpful for beginners and maybe old dves as mine if ther is an action named explain or whatever to lower a code block to a classic simple C#/VB code and show it in a readoly code window. Pattern matching expressions are in top of things that may need explanation. I may go far and say every new concept since Roslyn can be considered hard and nee to be explained. This can be a useful educational feature, and ease the pain for new team members that joins a large project. VS offers to simplify expressions which in most cases means shorten them into a complex modern syntax! We may need an action on the opposite direction. This seems a lot of work, but it can make use of the Roslyn code itself if it lowers these statements.
timiil
@timiil

roslyn only emits IL - but it doesn't modify it

i am looking for some 'name obfuscation Analyzer' or 'string encrypt Analyzer' ... 'XXX protect sourcecode Analyzer' things that build from roslyn...

Bernd Baumanns
@bernd5
if you have the csharp source you can write some rewriters which renames locals and non public types / methods
something like this
Bernd Baumanns
@bernd5
I would avoid arabic chars
timiil
@timiil
:)
Bernd Baumanns
@bernd5
I would name them a1, a2, a3....
but unicode should work, too.
or perhaps something like obf_local_1
timiil
@timiil
are not these task can be done by Analyzer??
Bernd Baumanns
@bernd5
no, an analyzer produces just diagnostic AFAIK
it would be a pre compile step
Yair Halberstadt
@YairHalberstadt
@VBAndCs that's basically what decompilers do - e.g. sharplab
timiil
@timiil
who produce the tons of 'Change Code Suggestion' in the vs ??
Bernd Baumanns
@bernd5
these are called "Code Fix"
timiil
@timiil
may be my missunderstanding that these are from roslyn
Bernd Baumanns
@bernd5
the are developed by the VS team
no they are from roslyn - that is right
timiil
@timiil
so , how can i write some anti human reading CodeFix rule ?
Bernd Baumanns
@bernd5
CodeFix is more than you need - a CodeFix adds some VS integration code
timiil
@timiil
oh, sounds bad. sounds that related by IDE, but not dotnet CLR
Bernd Baumanns
@bernd5
you could write a simple console app which loads the original source and produces "obfuscated" source which is than compiled to IL via the normal build pipeline
Yes, CodeFixes are IDE related - but what you want is not IDE related
timiil
@timiil
thanks for your kindly reply, a lot of knowlege knowed toninght and i should keep learning more
Bernd Baumanns
@bernd5
When you write your obfuscator you have to care about e.g. nameof() and reflection
because those names would change, too.
If you need further help - please ask.
timiil
@timiil
sure , very thanks :)
Yair Halberstadt
@YairHalberstadt
@timiil most obfuscators work with raw IL. They already exist so not sure why you would roll your own
timiil
@timiil
one reason is , IL changing this very hacking, and the opensource solution is so few amount.
Yair Halberstadt
@YairHalberstadt
Modifying IL is much safer, since it's easier to know what's safe to change and what's not.
Bernd Baumanns
@bernd5
yes - on IL level getting all semantics is quite complicated
but renaming locals would be very simple for example
Yair Halberstadt
@YairHalberstadt
For example you might rename an internal method named GetEnumerator and break a foreach.
timiil
@timiil
the second reason is , i think we have the source code, so if we use some skillful rewrite rule onto the sourcecode, and then build from roslyn, that sounds is very ...Nature