Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/compilers/CSharp/Warnversion Warning Waves.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The compiler shipped with .NET 11 (the C# 15 compiler) contains the following wa
| Warning ID | Description |
|------------|-------------|
| CS9368 | [RequiresUnsafeAttribute is only valid under the updated memory safety rules](https://github.com/dotnet/csharplang/issues/9704) |
| CS9377 | [The 'unsafe' modifier does not have any effect here under the current rules](https://github.com/dotnet/csharplang/issues/9704) |

## Warning level 10

Expand Down
8 changes: 8 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -8276,6 +8276,14 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>An unsafe context is required for constructor '{0}' marked as 'RequiresUnsafe' or 'extern' to satisfy the 'new()' constraint of type parameter '{1}' in '{2}'</value>
<comment>'RequiresUnsafe', 'extern', and 'new()' should not be localized. {2} is the generic method or type.</comment>
</data>
<data name="WRN_UnsafeMeaningless" xml:space="preserve">
<value>The 'unsafe' modifier does not have any effect here under the current rules.</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<value>The 'unsafe' modifier does not have any effect here under the current rules.</value>
<value>The 'unsafe' modifier does not have any effect here under the memory safety current rules.</value>

<comment>'unsafe' is a keyword, should not be localized.</comment>
</data>
<data name="WRN_UnsafeMeaningless_Title" xml:space="preserve">
<value>The 'unsafe' modifier does not have any effect here under the current rules.</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<value>The 'unsafe' modifier does not have any effect here under the current rules.</value>
<value>The 'unsafe' modifier does not have any effect here under the memory safety current rules.</value>

<comment>'unsafe' is a keyword, should not be localized.</comment>
</data>
<data name="ERR_NoAwaitOnAsyncEnumerable" xml:space="preserve">
<value>'{0}' does not contain a definition for '{1}' and no accessible extension method '{1}' accepting a first argument of type '{0}' could be found (did you mean to iterate over the async collection with 'await foreach' instead?)</value>
<comment>'await foreach' is not localizable</comment>
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,7 @@ internal enum ErrorCode
ERR_UnionConstructorCallsDefaultConstructor = 9375,

ERR_UnsafeConstructorConstraint = 9376,
WRN_UnsafeMeaningless = 9377,

// Note: you will need to do the following after adding errors:
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ internal static int GetWarningLevel(ErrorCode code)
switch (code)
{
case ErrorCode.WRN_RequiresUnsafeAttributeLegacyRules:
case ErrorCode.WRN_UnsafeMeaningless:
// Warning level 11 is exclusively for warnings introduced in the compiler
// shipped with dotnet 11 (C# 15) and that can be reported for pre-existing code.
return 11;
Expand Down Expand Up @@ -2587,6 +2588,7 @@ or ErrorCode.ERR_InstanceFieldInUnion
or ErrorCode.ERR_InstanceCtorWithOneParameterInUnion
or ErrorCode.ERR_UnionConstructorCallsDefaultConstructor
or ErrorCode.ERR_UnsafeConstructorConstraint
or ErrorCode.WRN_UnsafeMeaningless
=> false,
};
#pragma warning restore CS8524 // The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ private DeclarationModifiers MakeModifiers(TypeKind typeKind, BindingDiagnosticB
diagnostics.Add(ErrorCode.ERR_SealedStaticClass, GetFirstLocation(), this);
}

if (!modifierErrors &&
typeKind == TypeKind.Delegate &&
(mods & DeclarationModifiers.Unsafe) == DeclarationModifiers.Unsafe &&
this.ContainingModule.UseUpdatedMemorySafetyRules)
{
diagnostics.Add(ErrorCode.WRN_UnsafeMeaningless, GetFirstLocation());
}

switch (typeKind)
{
case TypeKind.Interface:
Expand Down
10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading