Skip to content

Commit

Permalink
Merge pull request #12 from mob-sakai/develop
Browse files Browse the repository at this point in the history
Release 3.5.0
  • Loading branch information
mob-sakai committed Sep 8, 2020
2 parents 43e8d4e + aad988e commit 79a3d6b
Show file tree
Hide file tree
Showing 13,285 changed files with 155,515 additions and 66,062 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .github/workflows/roslyn_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ jobs:
- uses: actions/checkout@v2
with:
ref: 'roslyn'
fetch-depth: 0

- name: Update roslyn
run: |
# Get version from issue title.
VERSION=`echo '${{ github.event.issue.title }}' | awk -F "[v: ]" '{print $NF}'`
echo ::set-env name=VERSION::${VERSION}
echo " >>>> VERSION = ${VERSION}"
# Find sha1 from nuget page.
SHA1=`curl -L https://www.nuget.org/packages/Microsoft.Net.Compilers.Toolset/${VERSION} \
| grep https://github.com/dotnet/roslyn/commit/ \
| sed -e 's/.*\([0-9a-f]\{40\}\).*$/\1/' \
| head -n 1`
echo " >>>> SHA1 = ${SHA1}"
# Git settings.
git remote set-url origin https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }}.git
Expand All @@ -42,6 +45,7 @@ jobs:
# Subtree merge from dotnet/roslyn.
[ -d roslyn ] && CMD=pull || CMD=add
echo " >>>> CMD = ${CMD}"
git subtree ${CMD} --prefix=roslyn --squash https://github.com/dotnet/roslyn.git ${SHA1} -m "Merge roslyn ${VERSION}" -m "https://github.com/dotnet/roslyn/commit/${SHA1}"
# Push.
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/roslyn_update_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ jobs:
- uses: actions/checkout@v2
with:
ref: 'roslyn'
fetch-depth: 0

- name: Update Roslyn (test)
run: |
# Get version from issue title.
VERSION=`echo '${{ github.event.issue.title }}' | awk -F "[v: ]" '{print $NF}'`
echo ::set-env name=VERSION::${VERSION}
echo " >>>> VERSION = ${VERSION}"
# Find sha1 from nuget page.
SHA1=`curl -L https://www.nuget.org/packages/Microsoft.Net.Compilers.Toolset/${VERSION} \
| grep https://github.com/dotnet/roslyn/commit/ \
| sed -e 's/.*\([0-9a-f]\{40\}\).*$/\1/' \
| head -n 1`
echo " >>>> SHA1 = ${SHA1}"
# Git settings.
git remote set-url origin https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }}.git
Expand All @@ -42,6 +45,7 @@ jobs:
# Subtree merge from dotnet/roslyn.
[ -d roslyn ] && CMD=pull || CMD=add
echo " >>>> CMD = ${CMD}"
git subtree ${CMD} --prefix=roslyn --squash https://github.com/dotnet/roslyn.git ${SHA1} -m "Merge roslyn ${VERSION}" -m "https://github.com/dotnet/roslyn/commit/${SHA1}"
# Push.
Expand Down
17 changes: 0 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,5 @@
* add MetadataImportOptions.All to compilation options ([eeec095](https://github.com/mob-sakai/OpenSesame/commit/eeec095e9abab374a6dc1d0638c1782fabc68df5))
* allow unsafe ([c17c869](https://github.com/mob-sakai/OpenSesame/commit/c17c8693c0158d55c2dd9bab012f5a9e3eb60cf7))
* change package name ([63b70ba](https://github.com/mob-sakai/OpenSesame/commit/63b70ba56cc71158234278dd4966374304e65554))
* change tool logo (cli) ([8f88f25](https://github.com/mob-sakai/OpenSesame/commit/8f88f25a18141791ee81f91851adb1e6bf3d591a))
* disable all access checks ([bd285cd](https://github.com/mob-sakai/OpenSesame/commit/bd285cda6dc1811c5f57fef237c871b814b4278e))
* disable all access checks (again) ([58909d5](https://github.com/mob-sakai/OpenSesame/commit/58909d5d3bbe0708418b5cd7d53d4f6ebbaacec8))
* inject IgnoresAccessChecksToAttribute automatically ([288fa86](https://github.com/mob-sakai/OpenSesame/commit/288fa8608226757b75203534bc616a9f3e523939))
* revert “disable all access checks” ([61abfcd](https://github.com/mob-sakai/OpenSesame/commit/61abfcd17d0f1d380300916c0937ef410e12a550))

# [3.4.0-beta.4](https://github.com/mob-sakai/OpenSesame/compare/v3.4.0-beta.3...v3.4.0-beta.4) (2020-08-12)


### Features

* disable all access checks (again) ([58909d5](https://github.com/mob-sakai/OpenSesame/commit/58909d5d3bbe0708418b5cd7d53d4f6ebbaacec8))

# [3.4.0-beta.3](https://github.com/mob-sakai/OpenSesame/compare/v3.4.0-beta.2...v3.4.0-beta.3) (2020-08-07)


### Features

* inject IgnoresAccessChecksToAttribute automatically ([288fa86](https://github.com/mob-sakai/OpenSesame/commit/288fa8608226757b75203534bc616a9f3e523939))
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ For more information, See [the great article by Filip W][ignores-access].
[reflection]: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/reflection
[ignores-access]: https://www.strathweb.com/2018/10/no-internalvisibleto-no-problem-bypassing-c-visibility-rules-with-roslyn/

### For "bridge" assembly

If you use an assembly (*.dll) generated by the OpenSesame compiler in another project, you do not need to use the OpenSesame compiler again.

This means that a "bridge" assembly to another assembly can be easily generated.

### Changes from original roslyn

* Change the names of the packages `Microsoft.*` to `OpenSesame.*`
Expand All @@ -37,6 +43,7 @@ For more information, See [the great article by Filip W][ignores-access].

### Supported frameworks

* Support C# 8.0
* .Net Framework 4.7 or later
* .Net Core 2.0 or later
* .Net Standard 2.0 or later
Expand Down Expand Up @@ -96,6 +103,79 @@ Use a unity package [com.coffee.open-sesame-compiler](https://github.com/mob-sak

<br><br><br><br>

## Unsupported Features

### Set/get value into readonly field

Use reflection

### IDE support

Use Csc-Manager to modify your VisualStudio Code and C# extension.
- csc-manager enable-vscode: Show internals/privates in other assembly.
- csc-manager disable-vscode: Hide them.

<br><br><br><br>

## How does the OpenSesame compiler affect the generated assemblies?

When [Program.cs][code] is compiled by `OpenSesame.Net.Compilers.Toolset`, the changes are as follows:

[code]: https://github.com/mob-sakai/OpenSesame/blob/master/Tests/PrivateLibrary.Console/Program.cs

```diff
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
+using System.Security;
+using System.Security.Permissions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
+[assembly: IgnoresAccessChecksTo("PrivateLibrary")]
[assembly: TargetFramework(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("PrivateLibrary.Console")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PrivateLibrary.Console")]
[assembly: AssemblyTitle("PrivateLibrary.Console")]
+[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
+[module: UnverifiableCode]
+namespace System.Runtime.CompilerServices
+{
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+ public class IgnoresAccessChecksToAttribute : Attribute
+ {
+ public string AssemblyName
+ {
+ get;
+ }
+
+ public IgnoresAccessChecksToAttribute(string assemblyName)
+ {
+ AssemblyName = assemblyName;
+ }
+ }
+}
namespace PrivateLibrary.Console
{
internal class Program
{
private static void Main(string[] args)
{
System.Console.WriteLine(new InternalClass().privateStringField);
}
}
}
```

<br><br><br><br>

## Develop

### Update Roslyn version
Expand Down
56 changes: 56 additions & 0 deletions Tests/PrivateLibrary.Bridge/Bridge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;

[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute("PrivateLibrary")]
namespace PrivateLibrary.Bridges
{
/// <summary>
/// Internal Class Bridge
/// </summary>
public class InternalClassBridge
{
/// <summary>
/// private String Field
/// </summary>
public string privateStringField = new InternalClass().privateStringField;

/// <summary>
/// private Static String Field
/// </summary>
public static string privateStaticStringField = InternalClass.privateStaticStringField;

/// <summary>
/// Public Static Method
/// </summary>
public static string PublicStaticMethod()
{
return InternalClass.PublicStaticMethod();
}


/// <summary>
/// Private Static Method
/// </summary>
public static string PrivateStaticMethod()
{
return InternalClass.PrivateStaticMethod();
}


/// <summary>
/// Public Method
/// </summary>
public string PublicMethod()
{
return new InternalClass().PublicMethod();
}


/// <summary>
/// Private Method
/// </summary>
public string PrivateMethod()
{
return new InternalClass().PrivateMethod();
}
}
}
15 changes: 15 additions & 0 deletions Tests/PrivateLibrary.Bridge/PrivateLibrary.Bridge.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PrivateLibrary\PrivateLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenSesame.Net.Compilers.Toolset" Version="3.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Tests/PrivateLibrary.Console/PrivateLibrary.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PrivateLibrary\PrivateLibrary.csproj" />
<ProjectReference Include="..\PrivateLibrary.Bridge\PrivateLibrary.Bridge.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenSesame.Net.Compilers.Toolset" Version="3.4.0">
Expand Down
9 changes: 7 additions & 2 deletions Tests/PrivateLibrary.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using System;
using PrivateLibrary.Bridges;

[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute("PrivateLibrary")]
namespace PrivateLibrary.Console
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine(new InternalClass().privateStringField);
System.Console.WriteLine(InternalClassBridge.privateStaticStringField);
System.Console.WriteLine(InternalClassBridge.PublicStaticMethod());
System.Console.WriteLine(InternalClassBridge.PrivateStaticMethod());
System.Console.WriteLine(new InternalClassBridge().privateStringField);
System.Console.WriteLine(new InternalClassBridge().PublicMethod());
System.Console.WriteLine(new InternalClassBridge().PrivateMethod());
}
}
}
3 changes: 3 additions & 0 deletions roslyn/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,6 @@ csharp_space_between_square_brackets = false
csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true

# warning RS0037: PublicAPI.txt is missing '#nullable enable'
dotnet_diagnostic.RS0037.severity = none
3 changes: 0 additions & 3 deletions roslyn/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ $RECYCLE.BIN/
# Mac desktop service store files
.DS_Store

# Visual Studio Code
.vscode/

# JetBrains Rider
.idea/

Expand Down
27 changes: 27 additions & 0 deletions roslyn/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Compilers/CSharp/csc/bin/Debug/netcoreapp2.1/csc.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Compilers/CSharp/csc",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
39 changes: 39 additions & 0 deletions roslyn/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "./build.cmd",
"type": "shell",
"args": [
],
"problemMatcher": "$msCompile",
"group": "build"
},
{
"label": "build skip analyzers",
"command": "./build.cmd",
"type": "shell",
"args": [
"-skipAnalyzers"
],
"problemMatcher": "$msCompile",
"group": "build"
},
{
"label": "build csc skip analyzers",
"command": "dotnet",
"type": "shell",
"args": [
"msbuild",
"-p:UseRoslynAnalyzers=false",
"-p:GenerateFullPaths=true",
"src/Compilers/CSharp/csc/csc.csproj"
],
"problemMatcher": "$msCompile",
"group": "build"
}
]
}
4 changes: 2 additions & 2 deletions roslyn/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ These two blogs posts on contributing code to open source projects are good too:

## Coding Style

The Roslyn project is a member of the [.NET Foundation](https://github.com/orgs/dotnet) and follows the same [developer guide](https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md). The repo also includes [.editorconfig](http://editorconfig.org) files to help enforce this convention. Contributors should ensure they follow these guidelines when making submissions.
The Roslyn project is a member of the [.NET Foundation](https://github.com/orgs/dotnet) and follows the same [developer guide](https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/coding-style.md). The repo also includes [.editorconfig](http://editorconfig.org) files to help enforce this convention. Contributors should ensure they follow these guidelines when making submissions.

### CSharp

- **DO** use the coding style outlined in the [.NET Foundation Coding Guidelines](https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md)
- **DO** use the coding style outlined in the [.NET Runtime Coding Guidelines](https://github.com/dotnet/runtime/blob/master/docs/coding-guidelines/coding-style.md)
- **DO** use plain code to validate parameters at public boundaries. Do not use Contracts or magic helpers.

```csharp
Expand Down
2 changes: 1 addition & 1 deletion roslyn/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng\targets\Settings.props" />
Expand Down
2 changes: 1 addition & 1 deletion roslyn/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng\targets\Imports.targets" />
Expand Down

0 comments on commit 79a3d6b

Please sign in to comment.